From 3f01b647e5db73395b5a5e5f814225ce673e2506 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Sun, 21 Feb 2021 00:56:35 +0300 Subject: [PATCH] Work around ammeter' incompatibility with RSpec 4 See: - rspec/rspec-core#1821 - rspec/rspec-core#2874 - alexrothenberg/ammeter#64 - example failure (Ammeter::RSpec::Rails::GeneratorExampleGroup that defines destination is not included) https://github.com/rspec/rspec-core/pull/2874/checks?check_run_id=1942170588 Alternative to #2468 --- spec/spec_helper.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6d3c5a3f64..32a6c0f07d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -74,4 +74,14 @@ def self.run_all(reporter = nil) example.run end end + + # Work around ammeter's incompatibility with RSpec 4 + # TODO: Remove once https://github.com/alexrothenberg/ammeter/pull/64 is merged + generator_path_regex = Regexp.compile(%w[spec generators].join('[\\\/]') + '[\\\/]') + config.include Ammeter::RSpec::Rails::GeneratorExampleGroup, + :type => :generator + config.include Ammeter::RSpec::Rails::GeneratorExampleGroup, + :file_path => lambda { |file_path, metadata| + metadata[:type].nil? && generator_path_regex =~ file_path + } end