Module: OmniAuth::Test::StrategyTestCase
- Defined in:
- lib/omniauth/test/strategy_test_case.rb
Overview
Support for testing OmniAuth strategies. Usage:
class MyStrategyTest < Test::Unit::TestCase
include OmniAuth::Test::StrategyTestCase
def strategy
# return the parameters to a Rack::Builder map call:
[MyStrategy.new, :some, :configuration, :options => 'here']
end
setup do
post '/auth/my_strategy/callback', :user => { 'name' => 'Dylan', 'id' => '445' }
end
end
Instance Method Summary collapse
Instance Method Details
#app ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/omniauth/test/strategy_test_case.rb', line 22 def app strategy = self.strategy Rack::Builder.new { use OmniAuth::Test::PhonySession use *strategy run lambda { |env| [200, {'Content-Type' => 'text/plain'}, [Rack::Request.new(env).params.key?('auth').to_s]] } }.to_app end |
#session ⇒ Object
31 32 33 |
# File 'lib/omniauth/test/strategy_test_case.rb', line 31 def session last_request.env['rack.session'] end |
#strategy ⇒ Object
35 36 37 |
# File 'lib/omniauth/test/strategy_test_case.rb', line 35 def strategy raise NotImplementedError.new('Including specs must define #strategy') end |