diff --git a/features/login.feature b/features/login.feature index 3fff7cf..f87265b 100644 --- a/features/login.feature +++ b/features/login.feature @@ -7,4 +7,9 @@ Feature: Login Page Given the login page When I log in with proper credentials Then I should see the secret page - + + Scenario: Unauthenticated User + Given the login page + When I log in with improper credentials + Then I should be on the login page + And I should be informed of my improper credentials diff --git a/features/logout.feature b/features/logout.feature index 251c445..a503507 100644 --- a/features/logout.feature +++ b/features/logout.feature @@ -1 +1,9 @@ -#Add your codez here +Feature: Logout Page + In order to sign out + As a user + I want to be able to logout + + Scenario: Logged In + Given I am a logged in user + When I click logout + Then I should see the login page diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index 61f803a..a17d78e 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -1,14 +1,27 @@ Given(/^the login page$/) do - #put your code here - pending + visit '/' end When(/^I log in with proper credentials$/) do - #put your code here - pending + fill_in 'username', with: 'credentials' + fill_in 'password', with: 'credentials' + click_button 'Login' +end + +When(/^I log in with improper credentials$/) do + fill_in 'username', with: 'improper' + fill_in 'password', with: 'credentials' + click_button 'Login' end Then(/^I should see the secret page$/) do - #put your code here - pending + expect(page).to have_content 'This is the secret page.' +end + +Then(/^I should be on the login page$/) do + expect(page).to have_content 'This is login page for users.' +end + +Then(/^I should be informed of my improper credentials$/) do + expect(page).to have_content 'Your username & password did not match' end diff --git a/features/step_definitions/logout_steps.rb b/features/step_definitions/logout_steps.rb index 251c445..eb65940 100644 --- a/features/step_definitions/logout_steps.rb +++ b/features/step_definitions/logout_steps.rb @@ -1 +1,14 @@ -#Add your codez here +Given(/^I am a logged in user$/) do + visit '/' + fill_in 'username', with: 'credentials' + fill_in 'password', with: 'credentials' + click_button 'Login' +end + +When(/^I click logout$/) do + click_link 'Logout' +end + +Then(/^I should see the login page$/) do + expect(page).to have_content 'This is login page for users.' +end