Created
November 18, 2011 08:38
-
-
Save krasio/1375915 to your computer and use it in GitHub Desktop.
Rails controller specs with Devise
This file contains hidden or 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/macros/authentication_macros.rb | |
module AuthenticationMacros | |
def sign_in_user | |
let(:current_user) { Factory.stub(:user) } | |
before do | |
sign_in current_user | |
warden.stub(:authenticate => current_user) | |
warden.stub(:authenticate! => current_user) | |
end | |
end | |
end |
This file contains hidden or 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/configuration.rb | |
RSpec.configure do |config| | |
config.include Devise::TestHelpers, :type => :controller | |
config.extend AuthenticationMacros, :type => :controller | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment