method
assert_no_difference
v4.0.2 -
Show latest stable
- Class:
ActiveSupport::Testing::Assertions
assert_no_difference(expression, message = nil, &block)public
Assertion that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.
assert_no_difference 'Article.count' do post :create, article: invalid_attributes end
An error message can be specified.
assert_no_difference 'Article.count', 'An Article should not be created' do post :create, article: invalid_attributes end
1Note
Takes array
Like assert_difference this method can take an array of expressions to evaluate all of them. For example:
assert_no_difference ['Publisher.count', 'User.count', 'Membership.count'] do post :create end
It creates an assertion for each item in the array. So this will add three assertions to your test.