Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Easy faking of user authentication in RSpec when using Devise
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
You can’t perform that action at this time.