Created
June 17, 2011 14:07
-
-
Save mattsnyder/1031474 to your computer and use it in GitHub Desktop.
Easy faking of user authentication in RSpec when using Devise
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 AuthenticationHelpers | |
# Example usage: login mock_user(Editor) | |
def login(user) | |
request.env['warden'] = mock(Warden, | |
:authenticate => user, | |
:authenticate! => user) | |
end | |
def mock_user(type, stubs={}) | |
mock_model(type, stubs).as_null_object | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment