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
A error message can be specified.
assert_no_difference 'Article.count', "An Article should not be destroyed" do post :create, :article => invalid_attributes end
# File activesupport/lib/active_support/testing/assertions.rb, line 76 def assert_no_difference(expression, message = nil, &block) assert_difference expression, 0, message, &block end
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.