1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
if RUBY_VERSION >= '1.9'
# require 'simplecov'
# require 'coveralls'
# SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
# SimpleCov.start do
# add_filter '/spec/'
# add_filter '/vendor/'
# minimum_coverage(92.93)
# end
end
require 'rspec'
require 'rack/test'
require 'omniauth'
require 'omniauth/test'
OmniAuth.config.logger = Logger.new('/dev/null')
RSpec.configure do |config|
config.include Rack::Test::Methods
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
class ExampleStrategy
include OmniAuth::Strategy
attr_reader :last_env
option :name, 'test'
def call(env)
options[:dup] ? super : self.call!(env)
end
def initialize(*args, &block)
super
@fail = nil
end
def request_phase
options[:mutate_on_request].call(options) if options[:mutate_on_request]
@fail = fail!(options[:failure]) if options[:failure]
@last_env = env
return @fail if @fail
fail('Request Phase')
end
def callback_phase
options[:mutate_on_callback].call(options) if options[:mutate_on_callback]
@fail = fail!(options[:failure]) if options[:failure]
@last_env = env
return @fail if @fail
fail('Callback Phase')
end
end
|