1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
# frozen_string_literal: true
# ensure test env
ENV['RACK_ENV'] = 'test'
# Third Party Libraries
require 'rspec'
require 'rspec/stubbed_env'
require 'silent_stream'
require 'addressable/uri'
require 'rspec/pending_for'
require 'rspec/block_is_expected'
# Extensions
require 'ext/backports'
DEBUG = ENV['DEBUG'] == 'true'
ruby_version = Gem::Version.new(RUBY_VERSION)
minimum_version = ->(version, engine = 'ruby') { ruby_version >= Gem::Version.new(version) && RUBY_ENGINE == engine }
actual_version = lambda do |major, minor|
actual = Gem::Version.new(ruby_version)
major == actual.segments[0] && minor == actual.segments[1] && RUBY_ENGINE == 'ruby'
end
debugging = minimum_version.call('2.7') && DEBUG
RUN_COVERAGE = minimum_version.call('2.6') && (ENV['COVER_ALL'] || ENV['CI_CODECOV'] || ENV['CI'].nil?)
ALL_FORMATTERS = actual_version.call(2, 7) && (ENV['COVER_ALL'] || ENV['CI_CODECOV'] || ENV['CI'])
if DEBUG
if debugging
require 'byebug'
elsif minimum_version.call('2.7', 'jruby')
require 'pry-debugger-jruby'
end
end
if RUN_COVERAGE
require 'simplecov' # Config file `.simplecov` is run immediately when simplecov loads
require 'codecov'
require 'simplecov-json'
require 'simplecov-lcov'
require 'simplecov-cobertura'
# This will override the formatter set in .simplecov
if ALL_FORMATTERS
SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.single_report_path = 'coverage/lcov.info'
end
SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::CoberturaFormatter, # XML for Jenkins
SimpleCov::Formatter::LcovFormatter,
SimpleCov::Formatter::JSONFormatter, # For CodeClimate
SimpleCov::Formatter::Codecov, # For CodeCov
]
end
end
# This gem
require 'oauth2'
# Library Configs
require 'config/multi_xml'
require 'config/faraday'
# RSpec Configs
require 'config/rspec/rspec_core'
require 'config/rspec/silent_stream'
VERBS = %i[get post put delete patch].freeze
|