Skip to content

Instantly share code, notes, and snippets.

@queso
Created August 6, 2009 19:15
Show Gist options
  • Save queso/163502 to your computer and use it in GitHub Desktop.
Save queso/163502 to your computer and use it in GitHub Desktop.
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in webrat_steps.rb
#
def path_to(page_name)
case page_name
when /the homepage/
'/'
when /the sign up page/
signup_path
when /the sign in page/
signin_path
# Add more mappings here.
# Here is a more fancy example:
#
# when /^(.*)'s profile page$/i
# user_profile_path(User.find_by_login($1))
else
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
"Now, go and add a mapping in #{__FILE__}"
end
end
end
World(NavigationHelpers)
Feature: Sign up
In order to get access to protected sections of the site
As a user
I should be able to sign up
Scenario: User signs up with invalid data
When I go to the sign up page
And I fill in "Email" with "bogusemail"
And I fill in "Password" with "passw0rd"
And I fill in "Password confirmation" with ""
And I press "Sign Up"
Then I should see error messages
Scenario: User signs up with valid data
When I go to the sign up page
And I fill in "Email" with "[email protected]"
And I fill in "Password" with "passw0rd"
And I fill in "Password confirmation" with "passw0rd"
And I press "Sign Up"
Then I should see "Thank you for signing up"
Then /^I should see error messages$/ do
response.body.should match /error(s)? prohibited/m
end
Given /^no user exists with an email of "(.*)"$/ do |email|
User.find_by_email(email).should be_nil
end
Given /^I am signed up and confirmed as "(.*)\/(.*)"$/ do |email, password|
user = Factory :valid_user,
:email => email,
:password => password,
:password_confirmation => password
end
Given /^I am signed up and signed in as "(.*)\/(.*)"$/ do |email, password|
user = Factory :valid_user,
:email => email,
:password => password,
:password_confirmation => password
When %{I sign in as "#{email}\/#{password}"}
end
When /^I sign in( with "remember me")? as "(.*)\/(.*)"$/ do |remember, email, password|
When %{I go to the sign in page}
And %{I fill in "Email" with "#{email}"}
And %{I fill in "Password" with "#{password}"}
And %{I check "Remember me"} if remember
And %{I press "Sign In"}
end
Then /^I should be signed in$/ do
controller.should be_signed_in
end
Then /^I should be signed out$/ do
controller.should be_signed_out
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment