Method: Warden.test_mode!

Defined in:
lib/warden.rb

.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