Created
February 27, 2012 13:36
-
-
Save cblunt/1923853 to your computer and use it in GitHub Desktop.
Handy helper methods for RSpecs, e.g. logging in as a user.
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
# spec/support/spec_support.rb | |
def login_as(user = nil) | |
user ||= Factory.create(:user) | |
session[:user_id] = user.id | |
end | |
def current_user | |
User.find(session[:user_id]) | |
rescue | |
nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment