-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
Message expectation unexpectedly failing when calling method with an object defining #== #914
Comments
PS: I understood from the documentation, that "Arguments that are passed to with are compared with actual arguments received using ==", and even though |
... and using an argument matcher explicitly is producing a similar error: it "testing argument matcher" do
expect_any_instance_of(Bar).to receive(:do_something_with).with(kind_of(Foo))
Bar.new.do_something_with(foo)
end
|
This is not an RSpec bug. Consider:
The problem here is that your Foo object is not playing well with other objects in the ruby system. Your object should be able to equality check itself against any other object that is passed to it. This is not the case, your object currently only can equality check itself against other objects that respond to |
Aaaaaarg, makes total sense, thanks a lot! |
Using RSpec 3.2.2 given the following example code:
I am seeing the example unexpectedly fail:
As soon as I comment out
Foo#==
the spec will pass. Is this something I am doing wrong? Is it bad style/unexpected to redefine #==? I also tried to define my own argument matcher for foos in order to workaround this, but without luck.I wasn't seeing this with an older version of RSpec.
The text was updated successfully, but these errors were encountered: