Closed tejasbubane closed 1 year ago
Repeating my reply from https://github.com/rubocop/rubocop-minitest/issues/215 for visibility:
I have a slight concern here: same
is less explicit than equal?
. It's not obvious which kind of comparison is being made (==
, eql?
, etc. ) unless you look at the implementation or docs.
I have a slight concern here: same is less explicit than equal?. It's not obvious which kind of comparison is being made (==, eql?, etc. ) unless you look at the implementation or docs.
This applies to assert_equal
too. To begin with ==
, eql?
, equal?
, etc are equally confusing for newcomers. I feel same
means same object which is checked by equal?
.
That's true. But assert_equal
is much more common, so it's better understood.
I'm not against this as a new cop, but there's some nuance, and I'm not sure how best to handle it.
I understand @andyw8's concern. However, equal?
is for confirming object identity, and "asssert_same
" seems to be a reasonable naming. After all, it is a point to keep in mind the difference between object identity comparison and object value comparison. I remember having a similar talk when writing the following rule:
https://rubystyle.guide/#identity-comparison
https://github.com/rubocop/rubocop-minitest/issues/215