Skip to content
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

New cop: Minitest/AssertSame #215

Closed
fatkodima opened this issue Dec 30, 2022 · 2 comments · Fixed by #219
Closed

New cop: Minitest/AssertSame #215

fatkodima opened this issue Dec 30, 2022 · 2 comments · Fixed by #219
Labels
enhancement New feature or request

Comments

@fatkodima
Copy link
Contributor

https://docs.ruby-lang.org/en/2.1.0/MiniTest/Assertions.html#method-i-assert_same

# bad
assert foo.equal?(bar)
refute foo.equal?(bar)

# good
assert_same foo, bar
refute_same foo, bar

In the rails/rails codebase by a quick regexp search I found 30+ offenses of this.

@koic
Copy link
Member

koic commented Dec 30, 2022

Good catch! This will open a PR in the style guide first.

@koic koic added the enhancement New feature or request label Dec 30, 2022
@andyw8
Copy link
Contributor

andyw8 commented Dec 30, 2022

I have a slight concern here: same is less explicit than equal?. It's not obvious what kind of comparison is being made (==, eql?, etc. ) unless you look at the implementation or docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants