diff --git a/.travis.yml b/.travis.yml index adabfea..e1fcb3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ rvm: - 2.5.5 - 2.6.2 # Uses unicode 12.0.0 - 2.6.3 # Uses unicode 12.1.0 + - 2.7.0 - ruby-head matrix: allow_failures: diff --git a/lib/core_extensions/regexp/examples.rb b/lib/core_extensions/regexp/examples.rb index dea007b..0777f4a 100644 --- a/lib/core_extensions/regexp/examples.rb +++ b/lib/core_extensions/regexp/examples.rb @@ -5,13 +5,13 @@ module Regexp # No core classes are extended in any way, other than the above two methods. module Examples def examples(**config_options) - RegexpExamples::Config.with_configuration(config_options) do + RegexpExamples::Config.with_configuration(**config_options) do examples_by_method(:result) end end def random_example(**config_options) - RegexpExamples::Config.with_configuration(config_options) do + RegexpExamples::Config.with_configuration(**config_options) do examples_by_method(:random_result).sample end end diff --git a/lib/regexp-examples/config.rb b/lib/regexp-examples/config.rb index cf8a1b3..3604919 100644 --- a/lib/regexp-examples/config.rb +++ b/lib/regexp-examples/config.rb @@ -27,10 +27,10 @@ def with_configuration(**new_config) original_config = config.dup begin - self.config = new_config + update_config(**new_config) result = yield ensure - self.config = original_config + update_config(**original_config) end result @@ -48,7 +48,7 @@ def with_configuration(**new_config) private - def config=(**args) + def update_config(**args) Thread.current[:regexp_examples_config].merge!(args) end diff --git a/regexp-examples.gemspec b/regexp-examples.gemspec index a74d3b3..f433c9f 100644 --- a/regexp-examples.gemspec +++ b/regexp-examples.gemspec @@ -17,6 +17,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'bundler', '> 1.7' s.add_development_dependency 'rake', '~> 12.0' s.add_development_dependency 'pry', '~> 0.12.0' + s.add_development_dependency 'warning', '~> 0.10.0' s.license = 'MIT' s.required_ruby_version = '>= 2.4.0' end diff --git a/spec/gem_helper.rb b/spec/gem_helper.rb index 651249f..5d64a96 100644 --- a/spec/gem_helper.rb +++ b/spec/gem_helper.rb @@ -6,13 +6,14 @@ require './lib/regexp-examples.rb' require 'helpers' require 'pry' +require 'warning' # Several of these tests (intentionally) use "weird" regex patterns, # that spam annoying warnings when running. # E.g. warning: invalid back reference: /\k/ # and warning: character class has ']' without escape: /[]]/ # This config disables those warnings. -$VERBOSE = nil +Warning.ignore(//, __dir__) RSpec.configure do |config| config.include Helpers diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index efdd8ec..bf77529 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -65,7 +65,7 @@ # This setting enables warnings. It's recommended, but in some cases may # be too noisy due to issues in dependencies. - config.warnings = true + config.warnings = false # Many RSpec users commonly either run the entire suite or an individual # file, and it's useful to allow more verbose output when running an