From c2465ddc2b3a29981bac31d2175cf35751d9a37a Mon Sep 17 00:00:00 2001 From: Cara Kane Date: Mon, 14 May 2018 10:18:03 -0400 Subject: [PATCH] finished challenge --- Gemfile.lock | 22 ++++++++++++++++++++++ features/logout.feature | 11 ++++++++++- features/step_definitions/login_steps.rb | 16 +++++++++------- features/step_definitions/logout_steps.rb | 20 +++++++++++++++++++- 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index da8b141..41829b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,6 +19,7 @@ GEM templater (>= 1.0.0) diff-lcs (1.2.5) extlib (0.9.16) + ffi (1.9.23) gherkin (2.12.2) multi_json (~> 1.3) haml (4.0.6) @@ -40,10 +41,26 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) + rb-fsevent (0.10.3) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + rspec (3.1.0) + rspec-core (~> 3.1.0) + rspec-expectations (~> 3.1.0) + rspec-mocks (~> 3.1.0) + rspec-core (3.1.7) + rspec-support (~> 3.1.0) rspec-expectations (3.1.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.1.0) + rspec-mocks (3.1.3) + rspec-support (~> 3.1.0) rspec-support (3.1.2) + sass (3.5.6) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) sinatra (1.4.5) rack (~> 1.4) rack-protection (~> 1.4) @@ -66,5 +83,10 @@ DEPENDENCIES cucumber-sinatra haml pry + rspec rspec-expectations + sass sinatra + +BUNDLED WITH + 1.16.1 diff --git a/features/logout.feature b/features/logout.feature index 251c445..7c38500 100644 --- a/features/logout.feature +++ b/features/logout.feature @@ -1 +1,10 @@ -#Add your codez here +Feature: Logout Page + In order to keep out the bad guys + As a user + I want to have leave my private page when I logout + + Scenario: Logged-in User + Given the secret page + When I log out + Then I should not see the secret page + diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index 61f803a..3e6c222 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -1,14 +1,16 @@ Given(/^the login page$/) do - #put your code here - pending + visit '/' + expect(page.body).to include("Capybara Secret Site") end When(/^I log in with proper credentials$/) do - #put your code here - pending + within("#session") do + fill_in 'username', with: 'example' + fill_in 'password', with: 'example' + end + click_button 'Login' end Then(/^I should see the secret page$/) do - #put your code here - pending -end + expect(page.body).to include("This is the secret page.") +end \ No newline at end of file diff --git a/features/step_definitions/logout_steps.rb b/features/step_definitions/logout_steps.rb index 251c445..c8fe7fb 100644 --- a/features/step_definitions/logout_steps.rb +++ b/features/step_definitions/logout_steps.rb @@ -1 +1,19 @@ -#Add your codez here +Given(/^the secret page$/) do + visit '/' + expect(page.body).to include("Capybara Secret Site") + within("#session") do + fill_in 'username', with: 'example' + fill_in 'password', with: 'example' + end + click_button 'Login' + expect(page.body).to include("This is the secret page.") +end + +When(/^I log out$/) do + click_link 'Logout' +end + +Then(/^I should not see the secret page$/) do + expect(page.body).not_to include("This is the secret page.") + expect(page.body).to include("This is login page for users.") +end \ No newline at end of file