2014-07-22 06:56:34 +00:00
|
|
|
if RUBY_VERSION >= '1.9'
|
|
|
|
require 'simplecov'
|
2017-02-12 08:51:20 +00:00
|
|
|
require 'coveralls'
|
|
|
|
|
|
|
|
SimpleCov.formatters = [
|
|
|
|
SimpleCov::Formatter::HTMLFormatter,
|
|
|
|
Coveralls::SimpleCov::Formatter
|
|
|
|
]
|
2014-07-22 06:56:34 +00:00
|
|
|
|
|
|
|
SimpleCov.start do
|
2015-12-19 11:37:05 +00:00
|
|
|
add_filter '/spec/'
|
|
|
|
add_filter '/vendor/'
|
2017-02-11 21:08:46 +00:00
|
|
|
minimum_coverage(92.5)
|
2014-07-22 06:56:34 +00:00
|
|
|
end
|
2014-01-16 04:00:52 +00:00
|
|
|
end
|
2011-10-30 20:04:18 +00:00
|
|
|
|
2010-11-03 18:19:10 +00:00
|
|
|
require 'rspec'
|
2010-06-13 02:34:19 +00:00
|
|
|
require 'rack/test'
|
2011-09-22 18:25:41 +00:00
|
|
|
require 'omniauth'
|
2011-09-03 18:08:07 +00:00
|
|
|
require 'omniauth/test'
|
2010-08-11 15:50:20 +00:00
|
|
|
|
2014-01-16 04:00:46 +00:00
|
|
|
OmniAuth.config.logger = Logger.new('/dev/null')
|
2012-04-12 20:50:13 +00:00
|
|
|
|
2011-04-22 18:13:24 +00:00
|
|
|
RSpec.configure do |config|
|
|
|
|
config.include Rack::Test::Methods
|
2014-05-30 18:42:00 +00:00
|
|
|
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
2012-10-10 08:32:55 +00:00
|
|
|
config.expect_with :rspec do |c|
|
|
|
|
c.syntax = :expect
|
|
|
|
end
|
2011-04-22 18:13:24 +00:00
|
|
|
end
|
2011-09-03 18:08:07 +00:00
|
|
|
|
2012-04-10 18:42:02 +00:00
|
|
|
class ExampleStrategy
|
|
|
|
include OmniAuth::Strategy
|
|
|
|
attr_reader :last_env
|
2014-01-16 04:00:46 +00:00
|
|
|
option :name, 'test'
|
|
|
|
|
|
|
|
def call(env)
|
2016-08-08 17:56:38 +00:00
|
|
|
options[:dup] ? super : call!(env)
|
2014-01-16 04:00:46 +00:00
|
|
|
end
|
|
|
|
|
2013-01-10 17:20:16 +00:00
|
|
|
def initialize(*args, &block)
|
|
|
|
super
|
|
|
|
@fail = nil
|
|
|
|
end
|
2014-01-16 04:00:46 +00:00
|
|
|
|
2012-04-10 18:42:02 +00:00
|
|
|
def request_phase
|
2015-11-12 17:57:59 +00:00
|
|
|
options[:mutate_on_request].call(options) if options[:mutate_on_request]
|
2012-04-10 18:42:02 +00:00
|
|
|
@fail = fail!(options[:failure]) if options[:failure]
|
|
|
|
@last_env = env
|
|
|
|
return @fail if @fail
|
2018-12-14 16:29:36 +00:00
|
|
|
|
2016-08-08 17:53:36 +00:00
|
|
|
raise('Request Phase')
|
2012-04-10 18:42:02 +00:00
|
|
|
end
|
2014-01-16 04:00:46 +00:00
|
|
|
|
2012-04-10 18:42:02 +00:00
|
|
|
def callback_phase
|
2015-11-12 17:57:59 +00:00
|
|
|
options[:mutate_on_callback].call(options) if options[:mutate_on_callback]
|
2012-04-10 18:42:02 +00:00
|
|
|
@fail = fail!(options[:failure]) if options[:failure]
|
|
|
|
@last_env = env
|
|
|
|
return @fail if @fail
|
2018-12-14 16:29:36 +00:00
|
|
|
|
2016-08-08 17:53:36 +00:00
|
|
|
raise('Callback Phase')
|
2012-04-10 18:42:02 +00:00
|
|
|
end
|
2012-04-24 11:11:57 +00:00
|
|
|
end
|