without_partial_double_verification incorrectly fails allow_any_instance_of
Created by: bbugh
We're upgrading gems, and came across this issue. We have some legacy code that unfortunately requires allow_any_instance_of
. We have been using a backport of without_partial_double_verification
which has been working fine. We've just upgraded to rspec 3.7 and now our legacy tests are failing because it looks like without_partial_double_verification
doesn't work with allow_any_instance_of
. Example spec code:
before do
without_partial_double_verification do
allow(Object).to receive(:success)
allow_any_instance_of(LegacyModule).to receive(:success)
end
end
With the back port, allow
and allow_any_instance_of
both work. With RSpec 3.7, the allow
works but allow_any_instance_of
fails with LegacyModule does not implement #success
.
Here's our current without_partial_double_verification
that works as expected.
def without_partial_double_verification(&block)
original_state = RSpec::Mocks.configuration.verify_partial_doubles?
RSpec::Mocks.configuration.verify_partial_doubles = false
yield
ensure
RSpec::Mocks.configuration.verify_partial_doubles = original_state
end