-
-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow_any_instance_of with block followed by expect_any_instance_of without block leads to doubled unshifting of the original object #1416
Comments
Are you calling my_method twice? As that would cause that, can you provide a reproducible snippet? |
The following spec is all green. class MyClass
def my_method(a, b)
end
end
RSpec.describe MyClass do
before do
allow_any_instance_of(MyClass).to receive(:my_method) { |instance, arg1, arg2|-
true # whatever
}-
end
it do
expect_any_instance_of(MyClass).to receive(:my_method).with(1,2)
MyClass.new.my_method(1, 2)
end
it do
expect(MyClass.new.my_method(nil, nil)).to be(true)
end
end |
Thanks for looking, @pirj and @JonRowe. Here's a recreation of the failure:
This fails with |
I believe the issue is related to |
Your environment
Steps to reproduce
In a before block I have:
then in a spec I have:
Expected behavior
My expectation is that the allowed implementation would be called
Actual behavior
The allowed implementation is called, but it recurses once and ends of with the orig_object being passed to both
instance
andarg1
. This, understandably leads to problems.Partial Stacktrace
You can see where it jumps into
invoke
twice.The text was updated successfully, but these errors were encountered: