Skip to content

Instantly share code, notes, and snippets.

@perryqh
Created November 12, 2009 22:34
Show Gist options
  • Save perryqh/233375 to your computer and use it in GitHub Desktop.
Save perryqh/233375 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 do_login(uname, pw)
visit '/login'
fill_in("username", :with => uname)
fill_in("Password", :with => pw)
click_button("Log in")
end
When /^I login with (.+)$/ do |unamepw|
split = unamepw.split(/\//)
do_login(split[0], split[1])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment