omniauth--omniauth/spec/helper.rb

70 lines
1.6 KiB
Ruby
Raw Normal View History

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'
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,
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)
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
require 'rspec'
require 'rack/test'
require 'rack/freeze'
require 'omniauth'
2011-09-03 18:08:07 +00:00
require 'omniauth/test'
2014-01-16 04:00:46 +00:00
OmniAuth.config.logger = Logger.new('/dev/null')
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
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
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
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
def initialize(*args, &block)
super
@fail = nil
end
2014-01-16 04:00:46 +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]
@last_env = env
return @fail if @fail
2016-08-08 17:53:36 +00:00
raise('Request Phase')
end
2014-01-16 04:00:46 +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]
@last_env = env
return @fail if @fail
2016-08-08 17:53:36 +00:00
raise('Callback Phase')
end
end