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