Module: Warden

Defined in:
lib/warden.rb,
lib/warden/hooks.rb,
lib/warden/proxy.rb,
lib/warden/config.rb,
lib/warden/errors.rb,
lib/warden/manager.rb,
lib/warden/version.rb,
lib/warden/test/mock.rb,
lib/warden/strategies.rb,
lib/warden/test/helpers.rb,
lib/warden/mixins/common.rb,
lib/warden/strategies/base.rb,
lib/warden/session_serializer.rb,
lib/warden/test/warden_helpers.rb

Defined Under Namespace

Modules: Hooks, Mixins, Strategies, Test Classes: Config, Manager, NotAuthenticated, Proxy, SessionSerializer, UserNotSet

Constant Summary collapse

VERSION =
"1.2.8"

Class Method Summary collapse

Class Method Details

.test_mode!Object

Provides helper methods to warden for testing.

To setup warden in test mode call the test_mode! method on warden

This will provide a number of methods. Warden.on_next_request(&blk) - captures a block which is yielded the warden proxy on the next request Warden.test_reset! - removes any captured blocks that would have been executed on the next request

Warden.test_reset! should be called in after blocks for rspec, or teardown methods for Test::Unit

Examples:

Warden.test_mode!

34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/warden.rb', line 34

def self.test_mode!
  unless Warden::Test::WardenHelpers === Warden
    Warden.extend Warden::Test::WardenHelpers
    Warden::Manager.on_request do |proxy|
      unless proxy.asset_request?
        while blk = Warden._on_next_request.shift
          blk.call(proxy)
        end
      end
    end
  end
  true
end