Skip to content

Instantly share code, notes, and snippets.

@lennart
Forked from jjhageman/user_steps.rb
Created March 23, 2010 17:15
Show Gist options
  • Save lennart/341415 to your computer and use it in GitHub Desktop.
Save lennart/341415 to your computer and use it in GitHub Desktop.
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 ||= Factory(:user)
end
def login
user
visit '/user_session/new'
fill_in("Login", :with => user.login)
fill_in("Password", :with => user.password)
click_button("Login")
end
Given /^I am a logged in user$/ do
login
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment