super_diff icon indicating copy to clipboard operation
super_diff copied to clipboard

When comparing arrays with nil values, NilClass is showing up in diff

Open mcmire opened this issue 4 years ago • 1 comments

Screen Shot 2020-05-23 at 2 38 23 PM

mcmire avatar May 24 '20 19:05 mcmire

We could treat nil and other primitives as un-diffable against the HavingAttributes matcher. I don't particularly like that because nil actually does have attributes {to_s: '', to_i: 0} and so on; SuperDiff would break if you're testing that the actual object matches one of those interfaces.

Even deeper of an issue is that we try to intelligently compare array elements when using the eq expectation between arrays. Per the Ruby docs, arrays are == if when the arrays are the same length and each corresponding element is equal per the == operator. We shouldn't use fuzzy comparison when using the eq matcher, but unfortunately, by the time RSpec calls into SuperDiff, we've lost context on what the failed matcher even was. I'm not sure how to address that.

jas14 avatar Oct 12 '24 00:10 jas14