Created
September 14, 2009 16:02
-
-
Save jjhageman/186744 to your computer and use it in GitHub Desktop.
Sample Cucumber step file for User models using Authlogic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module UserHelpers | |
def current_user_session | |
return @current_user_session if defined?(@current_user_session) | |
@current_user_session = UserSession.find | |
end | |
def current_user | |
return @current_user if defined?(@current_user) | |
@current_user = current_user_session && current_user_session.user | |
end | |
end | |
World(UserHelpers) | |
def user | |
@user ||= User.make | |
end | |
def login | |
user | |
visit '/login' | |
fill_in("Email", :with => user.email) | |
fill_in("Password", :with => user.password) | |
click_button("Login") | |
end | |
Given /^I am a logged in user$/ do | |
login | |
end | |
# Create n amount of additional users | |
Given /^there exists at least (\d+) other user$/ do |number| | |
@users = [] | |
number.scan(/\d/).join.to_i.times do |i| | |
@users[i] = User.make | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment