-
-
Couldn't load subscription status.
- Fork 285
Description
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:
assert_changes(-> { value }, 1) do
value += 1
end
However, the second argument to assert_changes is actually the message emitted on assertion failure, NOT the expected change delta. assert_changes uses from: and to: 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.