Skip to content

Commit

Permalink
Allow assertion that Array#reverse is not called (#1533)
Browse files Browse the repository at this point in the history
* Allow assertion that Array#reverse is not called
  • Loading branch information
brtrick authored and JonRowe committed Mar 10, 2023
1 parent fa3c139 commit 556456c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec/mocks/space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def verify_all

def reset_all
proxies.each_value { |proxy| proxy.reset }
@constant_mutators.reverse.each { |mut| mut.idempotently_reset }
any_instance_recorders.each_value { |recorder| recorder.stop_all_observation! }
any_instance_recorders.clear
@constant_mutators.reverse.each { |mut| mut.idempotently_reset }
end

def register_constant_mutator(mutator)
Expand Down
6 changes: 6 additions & 0 deletions spec/rspec/mocks/space_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def define_singleton_method_on_recorder_for(klass, name, &block)

expect(resets).to match_array([:dbl_1, :dbl_2])
end

it "allows Array#reverse to be stubbed" do
# This is a regression check solved in rspec/rspec-mocks#1533 previously
# this was not possible without a change to the implementation
expect_any_instance_of(Array).to_not receive(:reverse)
end
end

describe "#proxies_of(klass)" do
Expand Down

0 comments on commit 556456c

Please sign in to comment.