Sha256: 5483276f982c69f0987b24d76fd3cde636f24a7cf4b1516d8b2633ae66352f0e

Contents?: true

Size: 1.13 KB

Versions: 27

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8

module Warden
  module Test
    # A collection of test helpers for testing full stack rack applications using Warden
    # These provide the ability to login and logout on any given request
    # Note: During the teardown phase of your specs you should include: Warden.test_reset!
    module Helpers
      def self.included(base)
        ::Warden.test_mode!
      end

      # A helper method that will peform a login of a user in warden for the next request
      # Provide it the same options as you would to Warden::Proxy#set_user
      # @see Warden::Proxy#set_user
      # @api public
      def login_as(user, opts = {})
        Warden.on_next_request do |proxy|
          opts[:event] ||= :authentication
          proxy.set_user(user, opts)
        end
      end

      # Logs out a user from the session.
      # Without arguments, all users will be logged out
      # Provide a list of scopes to only log out users with that scope.
      # @see Warden::Proxy#logout
      # @api public
      def logout(*scopes)
        Warden.on_next_request do |proxy|
          proxy.logout(*scopes)
        end
      end
    end
  end
end

Version data entries

27 entries across 26 versions & 5 rubygems

Version Path
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/warden-1.2.3/lib/warden/test/helpers.rb
loyal_warden-2.0.1 lib/warden/test/helpers.rb
loyal_warden-0.0.5 lib/warden/test/helpers.rb
warden-1.2.3 lib/warden/test/helpers.rb
devise_sociable-0.1.0 vendor/bundle/gems/warden-1.0.6/lib/warden/test/helpers.rb
devise_sociable-0.1.0 vendor/bundle/gems/warden-1.2.1/lib/warden/test/helpers.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/warden-1.2.1/lib/warden/test/helpers.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/test/helpers.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/test/helpers.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/test/helpers.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/test/helpers.rb
warden-1.2.1 lib/warden/test/helpers.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/test/helpers.rb
warden-1.2.0 lib/warden/test/helpers.rb
warden-1.1.1 lib/warden/test/helpers.rb
warden-1.1.0 lib/warden/test/helpers.rb
warden-1.0.6 lib/warden/test/helpers.rb
warden-1.0.5 lib/warden/test/helpers.rb
warden-1.0.4 lib/warden/test/helpers.rb
warden-1.0.3 lib/warden/test/helpers.rb