Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simeonwillbanks/5454220 to your computer and use it in GitHub Desktop.
Save simeonwillbanks/5454220 to your computer and use it in GitHub Desktop.
#rails #devise #rspec
# 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
# 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