fix login cukes

This commit is contained in:
Florian Staudacher 2012-05-19 22:29:12 +02:00
parent 72f718c8c3
commit 9b563e39da
4 changed files with 21 additions and 12 deletions

View file

@ -1,17 +1,13 @@
@javascript
Feature: user authentication Feature: user authentication
Scenario: user logs in Scenario: user logs in
Given a user with username "ohai" and password "secret" Given a user with username "ohai" and password "secret"
When I go to the new user session page When I sign in manually as "ohai" with password "secret"
And I fill in "Username" with "ohai"
And I fill in "Password" with "secret"
And I press "Sign in"
Then I should be on the stream page Then I should be on the stream page
@javascript
Scenario: user logs out Scenario: user logs out
Given I am signed in Given I am signed in
And I click on my name in the header And I click on my name in the header
And I follow "Log out" And I follow "Log out"
And I wait for 1 seconds Then I should be on the new user session page
Then I should be on the new user session page

View file

@ -15,10 +15,13 @@ When /^I try to sign in$/ do
end end
When /^I try to sign in manually$/ do When /^I try to sign in manually$/ do
step %(I go to the new user session page) visit login_page
step %(I fill in "Username" with "#{@me.username}") login_as @me.username, @me.password
step %(I fill in "Password" with "#{@me.password}") end
step %(I press "Sign in")
When /^I (?:sign|log) in manually as "([^"]*)" with password "([^"]*)"$/ do |username, password|
visit login_page
login_as username, password
end end
When /^I (?:sign|log) in as "([^"]*)"$/ do |email| When /^I (?:sign|log) in as "([^"]*)"$/ do |email|

View file

@ -35,6 +35,10 @@ module NavigationHelpers
raise "Can't find mapping from \"#{page_name}\" to a path." raise "Can't find mapping from \"#{page_name}\" to a path."
end end
end end
def login_page
path_to "the new user session page"
end
end end
World(NavigationHelpers) World(NavigationHelpers)

View file

@ -15,6 +15,12 @@ module UserCukeHelpers
user.aspects.create(:name => "Besties") user.aspects.create(:name => "Besties")
user.aspects.create(:name => "Unicorns") user.aspects.create(:name => "Unicorns")
end end
def login_as(user, pass)
fill_in 'user_username', :with=>user
fill_in 'user_password', :with=>pass
click_button :submit
end
end end
World(UserCukeHelpers) World(UserCukeHelpers)