instance method
assert_no_difference
Ruby on Rails 5.2.8.1
Since v2.3.18Signature
assert_no_difference(expression, message = nil, &block)
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, params: { article: invalid_attributes } end
An error message can be specified.
assert_no_difference 'Article.count', 'An Article should not be created' do post :create, params: { article: invalid_attributes } end
Parameters
-
expressionreq -
messageopt = nil -
blockblock
Source
# File activesupport/lib/active_support/testing/assertions.rb, line 121
def assert_no_difference(expression, message = nil, &block)
assert_difference expression, 0, message, &block
end
Defined in activesupport/lib/active_support/testing/assertions.rb line 121
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Testing::Assertions