Created
March 19, 2015 09:01
-
-
Save arturictus/a5a30fd78cd42f642e43 to your computer and use it in GitHub Desktop.
Rspec-capybara login with warden
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/rails_helper.rb | |
# add to your rails_helper inside the | |
RSpec.configure do |config| | |
config.around(:each, type: :request) do |example| | |
Warden.test_mode! | |
example.run | |
Warden.test_reset! | |
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/warden_login.rb | |
def warden_login(factory = :admin_user, opts = {}) | |
let(:admin_user) { create(factory, opts) } | |
around(:each) do |example| | |
login_as(admin_user, :scope => :admin_user) | |
example.run | |
logout(:admin_user) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment