From 9b563e39dacc87fa2d6e2e046921272deb0c2ab4 Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Sat, 19 May 2012 22:29:12 +0200 Subject: [PATCH] fix login cukes --- features/logs_in_and_out.feature | 10 +++------- features/step_definitions/session_steps.rb | 11 +++++++---- features/support/paths.rb | 4 ++++ features/support/user_cuke_helpers.rb | 8 +++++++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/features/logs_in_and_out.feature b/features/logs_in_and_out.feature index 9f1862e14..ce7231446 100644 --- a/features/logs_in_and_out.feature +++ b/features/logs_in_and_out.feature @@ -1,17 +1,13 @@ +@javascript Feature: user authentication Scenario: user logs in Given a user with username "ohai" and password "secret" - When I go to the new user session page - And I fill in "Username" with "ohai" - And I fill in "Password" with "secret" - And I press "Sign in" + When I sign in manually as "ohai" with password "secret" Then I should be on the stream page - @javascript Scenario: user logs out Given I am signed in And I click on my name in the header And I follow "Log out" - And I wait for 1 seconds - Then I should be on the new user session page \ No newline at end of file + Then I should be on the new user session page diff --git a/features/step_definitions/session_steps.rb b/features/step_definitions/session_steps.rb index 5d5e16ac4..7a5ebb876 100644 --- a/features/step_definitions/session_steps.rb +++ b/features/step_definitions/session_steps.rb @@ -15,10 +15,13 @@ When /^I try to sign in$/ do end When /^I try to sign in manually$/ do - step %(I go to the new user session page) - step %(I fill in "Username" with "#{@me.username}") - step %(I fill in "Password" with "#{@me.password}") - step %(I press "Sign in") + visit login_page + login_as @me.username, @me.password +end + +When /^I (?:sign|log) in manually as "([^"]*)" with password "([^"]*)"$/ do |username, password| + visit login_page + login_as username, password end When /^I (?:sign|log) in as "([^"]*)"$/ do |email| diff --git a/features/support/paths.rb b/features/support/paths.rb index 85630615a..9f0ad1b56 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -35,6 +35,10 @@ module NavigationHelpers raise "Can't find mapping from \"#{page_name}\" to a path." end end + + def login_page + path_to "the new user session page" + end end World(NavigationHelpers) diff --git a/features/support/user_cuke_helpers.rb b/features/support/user_cuke_helpers.rb index 0a71edbb5..3d0b6653e 100644 --- a/features/support/user_cuke_helpers.rb +++ b/features/support/user_cuke_helpers.rb @@ -15,6 +15,12 @@ module UserCukeHelpers user.aspects.create(:name => "Besties") user.aspects.create(:name => "Unicorns") end + + def login_as(user, pass) + fill_in 'user_username', :with=>user + fill_in 'user_password', :with=>pass + click_button :submit + end end -World(UserCukeHelpers) \ No newline at end of file +World(UserCukeHelpers)