Skip to content

Instantly share code, notes, and snippets.

@padde
Last active August 29, 2015 14:22
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 padde/5a99678bec173d4c3052 to your computer and use it in GitHub Desktop.
Save padde/5a99678bec173d4c3052 to your computer and use it in GitHub Desktop.
Rails + Devise + RSpec = ❤️
# spec/support/devise.rb
module DeviseFeatureHelpers
def sign_in(user = nil, scope = :user)
user ||= build_stubbed :user
login_as user, scope: scope
end
end
RSpec.configure do |config|
# feature specs
config.include Warden::Test::Helpers, type: :feature
config.include DeviseFeatureHelpers, type: :feature
config.before(:suite) { Warden.test_mode! }
config.after(:each) { Warden.test_reset! }
# controller specs
config.include Devise::TestHelpers, type: :controller
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment