1
0
Fork 0
mirror of https://github.com/omniauth/omniauth.git synced 2022-11-09 12:31:49 -05:00
omniauth--omniauth/spec/helper.rb

70 lines
1.6 KiB
Ruby
Raw Normal View History

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