Skip to content

Instantly share code, notes, and snippets.

@millisami
Created June 23, 2010 12:10
Show Gist options
  • Save millisami/449847 to your computer and use it in GitHub Desktop.
Save millisami/449847 to your computer and use it in GitHub Desktop.
Given /^no user exists with an email "([^\"]*)"$/ do |email|
assert_nil User.find_by_email(email)
end
Given /^I am not logged in$/ do
@currnet_user = nil
end
When /^I login( with "Remember Me")? with "([^\"]*)" with password "([^\"]*)"$/ do |remember, email, password|
When %{I go to the path "/users/login"}
And %{I fill in "Email" with "#{email}"}
And %{I fill in "Password" with "#{password}"}
And %{I check "user_remember_me"} if remember
And %{I press "Sign in"}
end
Given /^I am logged in as #{capture_model}$/ do |model_name|
user = Factory(model_name.to_s.gsub(/ /,"_").to_sym, :password => "secret")
When %{I login with "#{user.email}" with password "secret"}
Then %{I should see "Signed in successfully."}
end
# http://groups.google.com/group/pickle-cucumber/browse_thread/thread/e69b084ed0407a67
# Used for has many association
# Given /#{capture_model} is one of #{capture_model}'s (/w+)$/ do |owned, owner, assoc|
# model!(owner).send(assoc) << model!(owned)
# end
Given /a #{capture_model} with role: (\w+) exists/ do |model, role|
user = create_model(model)
model!(user).roles = [role]
end
#Given /^the vendor user is logged in$/ do
# Given /^#{capture_model} exists with role$/ do |model_name|
# vendor_user = User.last
# puts vendor
# When %{I login with "#{vendor.users.first.email}" with password "secret"}
# Then %{I should see "Signed in successfully."}
# end
Then /^I should be signed in$/ do
And %{I should see "Signed in successfully."}
end
Then /^I should be signed out$/ do
And %{I should see "Signed out successfully."}
end
When /^I return next time$/ do
And %{I go to the homepage}
end
Given /^the user is logged in$/ do
user ||= User.last
When %{I login as "#{user.login}" with password "password"}
Then %{I should see "Login successful!"}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment