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
Show source
Register or log in to add new notes.
July 2, 2010
0 thanks

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.