From 3589c33e97a96e116f50d31fc04eeb51c2af5dd4 Mon Sep 17 00:00:00 2001 From: Deepak Bhimaraju Date: Tue, 31 May 2016 17:09:27 -0400 Subject: [PATCH] Completed Capybara --- Gemfile.lock | 14 ++++++++++++++ features/logout.feature | 12 +++++++++++- features/step_definitions/login_steps.rb | 12 ++++++------ features/step_definitions/logout_steps.rb | 8 +++++++- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index da8b141..7bbfbc8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,10 +40,19 @@ GEM 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.22) sinatra (1.4.5) rack (~> 1.4) rack-protection (~> 1.4) @@ -66,5 +75,10 @@ DEPENDENCIES cucumber-sinatra haml pry + rspec rspec-expectations + sass sinatra + +BUNDLED WITH + 1.12.5 diff --git a/features/logout.feature b/features/logout.feature index 251c445..bca9233 100644 --- a/features/logout.feature +++ b/features/logout.feature @@ -1 +1,11 @@ -#Add your codez here +Feature: Logout Feature + In order to keep out the bad guys + As a user + I want to have to be able to safely exit my appplication + + Scenario: Logout of Application + Given the login page + When I log in with proper credentials + Then I should see the secret page + Then I log out + Then I should successfully log out diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index 61f803a..08297d9 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 + expect(page).to have_content('This is login page for users.') + fill_in('username', :with => 'John') + fill_in('password', :with => 'John') + 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 diff --git a/features/step_definitions/logout_steps.rb b/features/step_definitions/logout_steps.rb index 251c445..d5e6c76 100644 --- a/features/step_definitions/logout_steps.rb +++ b/features/step_definitions/logout_steps.rb @@ -1 +1,7 @@ -#Add your codez here +When(/^I log out$/) do + click_link('Logout') +end + +Then(/^I should successfully log out$/) do + expect(page).to have_content('You have been logged out') +end