module OmniAuth::Test::StrategyTestCase

Support for testing OmniAuth strategies.

@example Usage

class MyStrategyTest < Test::Unit::TestCase
  include OmniAuth::Test::StrategyTestCase
  def strategy
    # return the parameters to a Rack::Builder map call:
    [MyStrategy, :some, :configuration, :options => 'here']
  end
  setup do
    post '/auth/my_strategy/callback', :user => { 'name' => 'Dylan', 'id' => '445' }
  end
end

Public Instance Methods

app() click to toggle source
# File lib/omniauth/test/strategy_test_case.rb, line 20
def app
  strat = strategy
  resp = app_response
  Rack::Builder.new do
    use(OmniAuth::Test::PhonySession)
    use(*strat)
    run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [resp || env.key?('omniauth.auth').to_s]] }
  end.to_app
end
app_response() click to toggle source
# File lib/omniauth/test/strategy_test_case.rb, line 30
def app_response
  nil
end
session() click to toggle source
# File lib/omniauth/test/strategy_test_case.rb, line 34
def session
  last_request.env['rack.session']
end
strategy() click to toggle source
# File lib/omniauth/test/strategy_test_case.rb, line 38
def strategy
  error = NotImplementedError.new('Including specs must define #strategy')
  raise(error)
end