Skip to content

Commit

Permalink
Avoid RSpec.world.instance_variable_set if we can
Browse files Browse the repository at this point in the history
This 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] rspec/rspec-core#2723
  • Loading branch information
agis committed Aug 8, 2020
1 parent 27a80e5 commit 855975d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/rspecq/worker.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 855975d

Please sign in to comment.