-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cop idea: Prefer assert_raises
over assert_raise
#351
Comments
I'm not sure whether |
But I would support a guideline to prefer |
rubocop/rubocop-rails#913 might be added for background context. |
Rails itself doesn't document |
For example, in the
https://guides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions But, I'm not sure what the actual situation is. |
Well, rails doesn't accept cosmetic changes. If someone where to come along wanting to change it the pr would just be rejected. Is there something which collects rails applications like https://github.com/eliotsykes/real-world-rails? I have seen this repo come up in the past but it hasn't been maintained for the last few years. |
The Ruby API itself is primarily named using the base form of verbs. For instance, in Ruby 3.2, |
That does indeed seem to be the prefered way for the ruby project itself. ruby/ruby@068f312 ruby/ruby@f159bbd A code search on github for Per these numbers Personally I would still go with |
When implementing a cop, default is important for users. Respecting Ruby's API naming and choosing |
When implementing cops, is there precedence for disabled by default and a required config key? Early adopters could opt in and must set their prefered style explicitly. It's not obvious which variant is better but I'd still like to try and work on this since it'll eventually go one way or another. If/When a conclusion is reached the config can be changed. |
Is your feature request related to a problem? Please describe.
Minitest by itself defines
assert_raises
and rails defined the aliasassert_raise
for it.Describe the solution you'd like
Prefer the native
assert_raises
overassert_raise
.Additional context
https://api.rubyonrails.org/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_raise
The text was updated successfully, but these errors were encountered: