aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2018-07-08 16:43:19 +0200
committerGitHub <noreply@github.com>2018-07-08 16:43:19 +0200
commit79edcaeb6ccd7f95029e36dd1a13369b119edfdf (patch)
treec4dc62c59c1a937c0ccbe8942204bb60fa24f59c /activesupport/lib
parent040eb98c2be6bfb2c50b4ad85e7031f9aa97f15e (diff)
parent4baad7bec63e5d842e36d9d25c1203900a499f67 (diff)
downloadrails-79edcaeb6ccd7f95029e36dd1a13369b119edfdf.tar.gz
rails-79edcaeb6ccd7f95029e36dd1a13369b119edfdf.tar.bz2
rails-79edcaeb6ccd7f95029e36dd1a13369b119edfdf.zip
Merge pull request #33318 from lxxxvi/multiple_expressions_in_assert_no_difference
Documentation and some tests for `assert_no_difference`
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb
index 6a56da384f..b27ac7ce99 100644
--- a/activesupport/lib/active_support/testing/assertions.rb
+++ b/activesupport/lib/active_support/testing/assertions.rb
@@ -113,11 +113,23 @@ module ActiveSupport
# post :create, params: { article: invalid_attributes }
# end
#
+ # A lambda can be passed in and evaluated.
+ #
+ # 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
+ #
+ # An array of expressions can also be passed in and evaluated.
+ #
+ # assert_no_difference [ 'Article.count', -> { Post.count } ] do
+ # post :create, params: { article: invalid_attributes }
+ # end
def assert_no_difference(expression, message = nil, &block)
assert_difference expression, 0, message, &block
end