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'
|
2020-12-04 19:40:33 +00:00
|
|
|
require 'simplecov-lcov'
|
|
|
|
|
|
|
|
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
|
2017-02-12 08:51:20 +00:00
|
|
|
|
|
|
|
SimpleCov.formatters = [
|
|
|
|
SimpleCov::Formatter::HTMLFormatter,
|
2020-12-04 19:40:33 +00:00
|
|
|
SimpleCov::Formatter::LcovFormatter,
|
2017-02-12 08:51:20 +00:00
|
|
|
Coveralls::SimpleCov::Formatter
|
|
|
|
]
|
2014-07-22 06:56:34 +00:00
|
|
|
|
|
|
|
SimpleCov.start do
|
2019-11-18 15:37:57 +00:00
|
|
|
add_filter ['/spec/', '/vendor/', 'strategy_macros.rb']
|
2017-02-11 21:08:46 +00:00
|
|
|
minimum_coverage(92.5)
|
2020-02-29 03:53:07 +00:00
|
|
|
maximum_coverage_drop(0.05)
|
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'
|
2020-12-10 18:04:28 +00:00
|
|
|
require 'rack/freeze'
|
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')
|
2020-12-03 03:16:51 +00:00
|
|
|
OmniAuth.config.request_validation_phase = nil
|
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]
|
2020-03-02 20:09:14 +00:00
|
|
|
@fail = fail!(options[:failure], options[:failure_exception]) if options[:failure]
|
2012-04-10 18:42:02 +00:00
|
|
|
@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]
|
2020-03-02 20:09:14 +00:00
|
|
|
@fail = fail!(options[:failure], options[:failure_exception]) if options[:failure]
|
2012-04-10 18:42:02 +00:00
|
|
|
@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
|