From 33c5fb2d45ec03b0a140a3d925383105fed634cd Mon Sep 17 00:00:00 2001 From: acchandl Date: Fri, 12 May 2017 21:55:14 -0400 Subject: [PATCH 1/2] adding login_steps. --- Gemfile.lock | 25 ++++++++++++++++++++++++ features/step_definitions/login_steps.rb | 12 ++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index da8b141..0dfd43a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -21,6 +21,8 @@ GEM extlib (0.9.16) gherkin (2.12.2) multi_json (~> 1.3) + gherkin (2.12.2-x86-mingw32) + multi_json (~> 1.3) haml (4.0.6) tilt highline (1.6.21) @@ -31,19 +33,35 @@ GEM multi_test (0.1.1) nokogiri (1.6.4.1) mini_portile (~> 0.6.0) + nokogiri (1.6.4.1-x86-mingw32) + mini_portile (~> 0.6.0) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) + pry (0.10.1-x86-mingw32) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + win32console (~> 1.3) rack (1.5.2) rack-protection (1.5.3) rack rack-test (0.6.2) rack (>= 1.0) + 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.4.23) sinatra (1.4.5) rack (~> 1.4) rack-protection (~> 1.4) @@ -54,11 +72,13 @@ GEM extlib (>= 0.9.5) highline (>= 1.4.0) tilt (1.4.1) + win32console (1.3.2-x86-mingw32) xpath (2.0.0) nokogiri (~> 1.3) PLATFORMS ruby + x86-mingw32 DEPENDENCIES capybara @@ -66,5 +86,10 @@ DEPENDENCIES cucumber-sinatra haml pry + rspec rspec-expectations + sass sinatra + +BUNDLED WITH + 1.13.7 diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index 61f803a..f42c461 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -1,14 +1,14 @@ 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 => 'goldie' + fill_in 'password', :with => 'goldie' + click_button 'Login' end Then(/^I should see the secret page$/) do - #put your code here - pending + expect(current_path).to eq '/dashboard' + end From 3f3c01a10968473495cd8105cd9c9834e590fac8 Mon Sep 17 00:00:00 2001 From: acchandl Date: Wed, 17 May 2017 21:56:29 -0400 Subject: [PATCH 2/2] added logout feature --- features/logout.feature | 10 +++++++++- features/step_definitions/login_steps.rb | 1 - features/step_definitions/logout_steps.rb | 20 +++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/features/logout.feature b/features/logout.feature index 251c445..d3dab8b 100644 --- a/features/logout.feature +++ b/features/logout.feature @@ -1 +1,9 @@ -#Add your codez here +Feature: Logout Page + In order to keep my privacy + As a user + I want to have to logout to keep my page secure + + Scenario: Log out User + Given I am on the secret page + When I click the logout button + Then I should return to the login page \ No newline at end of file diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index f42c461..b14f61b 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -10,5 +10,4 @@ Then(/^I should see the secret page$/) do expect(current_path).to eq '/dashboard' - end diff --git a/features/step_definitions/logout_steps.rb b/features/step_definitions/logout_steps.rb index 251c445..632fac3 100644 --- a/features/step_definitions/logout_steps.rb +++ b/features/step_definitions/logout_steps.rb @@ -1 +1,19 @@ -#Add your codez here +Given /^(.*) is logged in$/ do |name| + steps %Q{ + Given the user #{name} exists + Given I log in as #{name} + } +end + +When(/^I am on the secret page$/) do + visit '/dashboard' +end + +When(/^I click the logout button$/) do + url = URI.parse(current_url) + expect(url).to assert_current_path("http://localhost:4567/logout", url: true ) +end + +Then(/^I should return to the login page$/) do + expect(page).to have_content('You have been logged out.') +end \ No newline at end of file