About the message
This message, which kinda isn't an error, is shown when the assertion fails, but MiniTest fails to find a difference between the objects.
Check out this method.
diff
runs #inspect
on the two objects and runs a diff tool on that. If there is no diff, this message is shown.
In principle, you'd want two objects which aren't equal to have different output when inspected. This isn't written in stone though, and some classes in the ruby standard libraries don't fullfil this property, like Time
. When it comes to your own classes, maybe you've written a custom #inspect
method?
Regarding Time
, inspect only shows seconds, not fractions, but equality looks at fractions, so two time objects may not be equal but still look the same when inspected.
Regarding Array
, if objects included in it can be not equal but look the same when inspected, this will cause the message to be displayed.
If you get this message even though the inspect outputs are different, something is wrong with the diff tool. MiniTest tries to do some educated guesses about which diff tool to use. You can inspect the chosen diff tool by printing MiniTest::Assertions.diff
.
On object equality
If the real issue is that your objects aren't equal when you expect them to be, you should look at how the ==
method is defined in the respective classes. The default implementation looks at the object ids given to each object when instantiated, which is probably not what you want if for example dealing with objects that represent database rows.