From 31234a0c0c79839e30945249020e075e3dc81637 Mon Sep 17 00:00:00 2001 From: Agis Anastasopoulos Date: Sat, 8 Aug 2020 23:30:35 +0300 Subject: [PATCH] Avoid RSpec.world.instance_variable_set if we can That is fortunately only needed in rspec-core versions equal or less than 3.9.1, since 3.9.2 includes the relevant fix[1]. [1] https://github.com/rspec/rspec-core/pull/2723 --- lib/rspecq/worker.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/rspecq/worker.rb b/lib/rspecq/worker.rb index 43c908d..970966f 100644 --- a/lib/rspecq/worker.rb +++ b/lib/rspecq/worker.rb @@ -156,8 +156,11 @@ def try_publish_queue!(queue) def reset_rspec_state! RSpec.clear_examples - # TODO: remove after https://github.com/rspec/rspec-core/pull/2723 - RSpec.world.instance_variable_set(:@example_group_counts_by_spec_file, Hash.new(0)) + # see https://github.com/rspec/rspec-core/pull/2723 + if Gem::Version.new(RSpec::Core::Version::STRING) <= Gem::Version.new("3.9.1") + RSpec.world.instance_variable_set( + :@example_group_counts_by_spec_file, Hash.new(0)) + end # RSpec.clear_examples does not reset those, which causes issues when # a non-example error occurs (subsequent jobs are not executed)