aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-09-24 14:19:27 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-09-24 14:19:27 -0300
commitadfb823af52d368fa4d88731a9809a314ad884ad (patch)
tree2b23c1dd5a71288623faed95d6118bbe2ece9736 /activesupport/lib
parent9b966f6233fb9587bea476020dd9e08e50c03198 (diff)
parent564b162015bebe4d393ee1160f081aae8c4da1d7 (diff)
downloadrails-adfb823af52d368fa4d88731a9809a314ad884ad.tar.gz
rails-adfb823af52d368fa4d88731a9809a314ad884ad.tar.bz2
rails-adfb823af52d368fa4d88731a9809a314ad884ad.zip
Merge pull request #21754 from lucasmazza/lm-assert-difference
Make `assert_difference` return the result of the yielded block.
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb
index d87ce3474d..ae8c15d8bf 100644
--- a/activesupport/lib/active_support/testing/assertions.rb
+++ b/activesupport/lib/active_support/testing/assertions.rb
@@ -68,13 +68,15 @@ module ActiveSupport
}
before = exps.map(&:call)
- yield
+ retval = yield
expressions.zip(exps).each_with_index do |(code, e), i|
error = "#{code.inspect} didn't change by #{difference}"
error = "#{message}.\n#{error}" if message
assert_equal(before[i] + difference, e.call, error)
end
+
+ retval
end
# Assertion that the numeric result of evaluating an expression is not