What
Rails controller spec helpers for Warden. If you're using Warden without Devise in rails, due to how ActionController sets up the test environment, custom test setup code is necessary.
Usage
# Gemfile
group :test do
gem 'warden-rspec-rails'
end
# spec_helper.rb
RSpec.configure do |c|
c.include Warden::Test::ControllerHelpers, type: :controller
endThis will define helper methods in controller tests that you can use to manage authentication, such as:
-
warden: Access theWarden::Proxy. -
login_as: Same as theWarden::Test::Helperslogin_asmethod. -
logout: Same as theWarden::Test::Helperslogoutmethod. -
unlogin: Removes the user(s) from the logged-in list, but leaves the session value so the user can be fetched on access.