aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/testing/assertions.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-08-04 14:07:23 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-08-04 14:07:40 -0700
commit2d2c9179adcd64e2125ea49d5d9517985bbccb01 (patch)
tree566cc2e2611eaf616527c4988cf3c59618fb072d /activesupport/lib/active_support/testing/assertions.rb
parent19ab8e4bc92bfbd04231bbac3f90cd3baa697ccc (diff)
downloadrails-2d2c9179adcd64e2125ea49d5d9517985bbccb01.tar.gz
rails-2d2c9179adcd64e2125ea49d5d9517985bbccb01.tar.bz2
rails-2d2c9179adcd64e2125ea49d5d9517985bbccb01.zip
fixing assert_difference issues on ruby 1.8
Diffstat (limited to 'activesupport/lib/active_support/testing/assertions.rb')
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb
index ba34e9853c..f3629ada5b 100644
--- a/activesupport/lib/active_support/testing/assertions.rb
+++ b/activesupport/lib/active_support/testing/assertions.rb
@@ -45,18 +45,19 @@ module ActiveSupport
# post :delete, :id => ...
# end
def assert_difference(expression, difference = 1, message = nil, &block)
- exps = Array.wrap(expression).map { |e|
- callee = e.respond_to?(:call) ? e : lambda { eval(e, block.binding) }
- [e, callee]
+ expressions = Array.wrap expression
+
+ exps = expressions.map { |e|
+ e.respond_to?(:call) ? e : lambda { eval(e, block.binding) }
}
- before = exps.map { |_, block| block.call }
+ before = exps.map { |e| e.call }
yield
- exps.each_with_index do |(code, block), i|
+ 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, block.call, error)
+ assert_equal(before[i] + difference, e.call, error)
end
end