Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Correctly reset config after tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GCorbel committed Mar 6, 2024
1 parent 18683bf commit 5688b2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 2 additions & 8 deletions spec/rspec/mocks/mutate_const_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ def change_const_value_to(value)
if RUBY_VERSION >= '3.1'
describe 'with global exclude_stubbed_classes_from_subclasses option set' do
include_context "with isolated configuration"

before do
RSpec::Mocks.configuration.exclude_stubbed_classes_from_subclasses = true
end
include_context "with stubbed classes excluded from subclasses"

it 'gives the same subclasses after rspec clears its mocks' do
original_subclasses = TestClass.subclasses
Expand Down Expand Up @@ -372,10 +369,7 @@ def change_const_value_to(value)
if RUBY_VERSION >= '3.1'
describe 'with global exclude_stubbed_classes_from_subclasses option set' do
include_context "with isolated configuration"

before do
RSpec::Mocks.configuration.exclude_stubbed_classes_from_subclasses = true
end
include_context "with stubbed classes excluded from subclasses"

it 'gives the same subclasses after rspec clears its mocks' do
original_subclasses = TestClass::Nested.subclasses
Expand Down
10 changes: 10 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,13 @@ def self.fake_matcher_description
RSpec::Mocks.configuration.syntax = orig_syntax
end
end

RSpec.shared_context "with stubbed classes excluded from subclasses" do
before do
RSpec::Mocks.configuration.exclude_stubbed_classes_from_subclasses = true
end

after do
RSpec::Mocks.configuration.exclude_stubbed_classes_from_subclasses = false
end
end

0 comments on commit 5688b2a

Please sign in to comment.