Commit 2f431fb3 authored by Thong Kuah's avatar Thong Kuah

Refactor to encapsulate in module

parent 52282d32
# frozen_string_literal: true # frozen_string_literal: true
if ENV.key?('RECORD_DEPRECATIONS') require 'deprecation_toolkit'
require 'deprecation_toolkit' require 'deprecation_toolkit/rspec'
require 'deprecation_toolkit/rspec'
DeprecationToolkit::Configuration.test_runner = :rspec module DeprecationToolkitEnv
DeprecationToolkit::Configuration.deprecation_path = 'deprecations' # Taken from https://github.com/jeremyevans/ruby-warning/blob/1.1.0/lib/warning.rb#L18
DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record def self.kwargs_warning
%r{warning: (?:Using the last argument (?:for `.+' )?as keyword parameters is deprecated; maybe \*\* should be added to the call|Passing the keyword argument (?:for `.+' )?as the last hash parameter is deprecated|Splitting the last argument (?:for `.+' )?into positional and keyword parameters is deprecated|The called method (?:`.+' )?is defined here)\n\z}
end
def self.configure!
return unless ENV.key?('RECORD_DEPRECATIONS')
# Enable ruby deprecations for keywords, it's suppressed by default in Ruby 2.7.2 # Enable ruby deprecations for keywords, it's suppressed by default in Ruby 2.7.2
Warning[:deprecated] = true Warning[:deprecated] = true
kwargs_warnings = [ DeprecationToolkit::Configuration.test_runner = :rspec
# Taken from https://github.com/jeremyevans/ruby-warning/blob/1.1.0/lib/warning.rb#L18 DeprecationToolkit::Configuration.deprecation_path = 'deprecations'
%r{warning: (?:Using the last argument (?:for `.+' )?as keyword parameters is deprecated; maybe \*\* should be added to the call|Passing the keyword argument (?:for `.+' )?as the last hash parameter is deprecated|Splitting the last argument (?:for `.+' )?into positional and keyword parameters is deprecated|The called method (?:`.+' )?is defined here)\n\z} DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [kwargs_warning]
] DeprecationToolkit::Configuration.behavior = DeprecationToolkit::Behaviors::Record
DeprecationToolkit::Configuration.warnings_treated_as_deprecation = kwargs_warnings end
end end
...@@ -13,6 +13,7 @@ end ...@@ -13,6 +13,7 @@ end
Warning[:deprecated] = true unless ENV.key?('SILENCE_DEPRECATIONS') Warning[:deprecated] = true unless ENV.key?('SILENCE_DEPRECATIONS')
require './spec/deprecation_toolkit_env' require './spec/deprecation_toolkit_env'
DeprecationToolkitEnv.configure!
require './spec/simplecov_env' require './spec/simplecov_env'
SimpleCovEnv.start! SimpleCovEnv.start!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment