-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Minitest/AssertWithExpectedArgument flags a common assertion in model tests. #126
Labels
bug
Something isn't working
Comments
koic
added a commit
to koic/rubocop-minitest
that referenced
this issue
Mar 22, 2021
Fixes rubocop#126. This PR marks `Minitest/AssertWithExpectedArgument` as unsafe. This cop is marked as unsafe, because it is not possible to determine whether the second argument of `assert` is a message or not.
8 tasks
koic
added a commit
to koic/rubocop-minitest
that referenced
this issue
Mar 22, 2021
Fixes rubocop#126. This PR marks `Minitest/AssertWithExpectedArgument` as unsafe. This cop is marked as unsafe, because it is not possible to determine whether the second argument of `assert` is a message or not.
koic
added a commit
that referenced
this issue
Mar 30, 2021
…as_unsafe [Fix #126] Mark `Minitest/AssertWithExpectedArgument` as unsafe
RuboCop Minitest 0.11.1 has been released with unsafe mark to the cop. In the future, if there are many similar issues, I think this cop can consider disabling it by default. Thank you for your feedback. |
Thank you for looking into this.
… On Mar 30, 2021, at 12:50 PM, Koichi ITO ***@***.***> wrote:
RuboCop Minitest 0.11.1 has been released with unsafe mark to the cop. In the future, if there are many similar issues, I think this cop can consider disabling it by default. Thank you for your feedback.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#126 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABQTUIQO2KOPSRNTWQLTST3TGH6OHANCNFSM4ZR4UFJQ>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The new Minitest/AssertWithExpectedArgument cop flags a valid assertion used in Rails model tests.
With a User class that has a required name attribute, a test for this may be written as:
The last assertion, assert @user.valid?, @user.errors.full_messages, is (or used to be) an acceptable way of returning an unexpected error message for an assert something.valid? statement that you expect to be true. Should the @user instance not be valid, any errors are displayed.
Obviously, once the unexpected condition is corrected, the @user.error.full_messages part of the statement is no longer needed. Our model tests, however, have about 1300 lines that use this structure.
The text was updated successfully, but these errors were encountered: