Sha256: 38384dbd13bcf297dc0ed034e366a8d82e25990af32c4390f0464d4bac933dea

Contents?: true

Size: 1.28 KB

Versions: 10

Compression:

Stored size: 1.28 KB

Contents

# encoding: utf-8
require 'forwardable'

require 'warden/mixins/common'
require 'warden/proxy'
require 'warden/manager'
require 'warden/errors'
require 'warden/session_serializer'
require 'warden/strategies'
require 'warden/strategies/base'

module Warden
  class NotAuthenticated < StandardError; end

  module Test
    autoload :WardenHelpers,  'warden/test/warden_helpers'
    autoload :Helpers,        'warden/test/helpers'
  end

  # Provides helper methods to warden for testing.
  #
  # To setup warden in test mode call the +test_mode!+ method on warden
  #
  # @example
  #   Warden.test_mode!
  #
  # 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
  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
end

Version data entries

10 entries across 10 versions & 5 rubygems

Version Path
warden-1.2.5 lib/warden.rb
warden-1.2.4 lib/warden.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/warden-1.2.3/lib/warden.rb
loyal_warden-2.0.1 lib/warden.rb
loyal_warden-0.0.5 lib/warden.rb
warden-1.2.3 lib/warden.rb
devise_sociable-0.1.0 vendor/bundle/gems/warden-1.2.1/lib/warden.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/warden-1.2.1/lib/warden.rb
warden-1.2.1 lib/warden.rb
warden-1.2.0 lib/warden.rb