-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
Prevent assert_changes with non-string message #1396
Comments
Working on this! |
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
ActiveSupport's assert_changes is often misused to check if an expression's value has changed by a specific delta during the execution of a block. For example:
However, the second argument to
assert_changes
is actually themessage
emitted on assertion failure, NOT the expected change delta.assert_changes
usesfrom:
andto:
named arguments to accept specific change values.It may be difficult to identify this mistake, as the assertion will pass as long as the expression changes by ANY value.
FYI assert_difference is probably what developers are looking for - it actually does accept an expected delta.
Describe the solution you'd like
Cop should prevent use of non-string message parameters for
assert_changes
.The text was updated successfully, but these errors were encountered: