ActiveSupport has a ton of great assertions that make writing tests a joy!
One such welcome change is the addition of the from
option to assert_no_changes
.
Let’s have a look at what changed.
Before
To test if an action changes the value of an object, there is a useful assertion that ActiveSupport provides.
This assertion has support for from
and to
parameters as well, making it easier to monitor changes.
It is also possible to monitor if the object does not change, using the following assertion,
However, we were not provided with a from
option for this assertion.
Hence, asserting that no change occurs from a fixed starting point was not easy to determine.
After
Thanks to this PR, we now have a from
option.
It makes it easy to assert that no change occurred during a transaction.
It permits asserting on the initial value that is expected not to change.