How can two objects seem to be identical but are not?
Have pickle_step that runs code "model!(owner).send(association).should == model!(target)"
When run in a tag (cucumber --tags @thisonescenario), owner and target are the same and the test passes.
When ran with rest of scenarios (cucumber), the owner and target are not the same.
After inspection (rdebug) the code says the classes aren'开发者_如何学Ct the same even though they really seem to be. Output of cucumber step is as follows:
expected: #<Content _id: content_1, _type: nil>
got: #<Content _id: content_1, _type: nil> (using ==)
Diff: (RSpec::Expectations::ExpectationNotMetError)
Note: == overloaded by Mongo library with code below:
def ==(other)
self.class == other.class &&
attributes["_id"] == other.attributes["_id"]
end
The _id comparison is true. The self.class == other.class is false.
Inspection of classes properties such as descendants, ancestors, etc. show they are the same.
Any ideas?
What if you use === instead == to compare the classes names?
something like
other === self && ...
精彩评论