method
assert_no_difference
v3.1.0 -
Show latest stable
-
1 note -
Class: ActiveSupport::Testing::Assertions
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (-2)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (-1)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (3)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (38)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
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
Register or
log in
to add new notes.
eric_programmer -
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.