Sha256: ab3ad9c002f96369804cfd87e9f4d4402649f821e8b8f8950ca5efb4436720ac
Contents?: true
Size: 1.38 KB
Versions: 7
Compression:
Stored size: 1.38 KB
Contents
module Warden::Spec module Helpers FAILURE_APP = lambda{|e|[401, {"Content-Type" => "text/plain"}, ["You Fail!"]] } def env_with_params(path = "/", params = {}) method = params.fetch(:method, "GET") Rack::MockRequest.env_for(path, :input => Rack::Utils.build_query(params), 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => "#{method}") end def setup_rack(app = nil, opts = {}, &block) app ||= block if block_given? # opts[:default_strategies] ||= [:password] # opts[:failure_app] ||= failure_app Rack::Builder.new do use Warden::Spec::Helpers::Session use Warden::Manager, opts do |manager| manager.failure_app = Warden::Spec::Helpers::FAILURE_APP manager.default_strategies :password end run app end end def valid_response [200,{'Content-Type' => 'text/plain'},'OK'] end def failure_app Warden::Spec::Helpers::FAILURE_APP end def success_app lambda{|e| [200, {"Content-Type" => "text/plain"}, ["You Win"]]} end class Session attr_accessor :app def initialize(app,configs = {}) @app = app end def call(e) e['rack.session'] ||= {} @app.call(e) end end # session end end
Version data entries
7 entries across 7 versions & 2 rubygems