aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-05-01 12:16:12 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-05-01 12:16:12 -0700
commitb8ccd0552473fbe0f346334e37b7d84481dd3533 (patch)
treef122676e5fb24aef5a35867851fc0c3a41cef11e /activesupport/lib
parent23eb81a3d1eb154a3aefe569408d1bb2ed63c554 (diff)
downloadrails-b8ccd0552473fbe0f346334e37b7d84481dd3533.tar.gz
rails-b8ccd0552473fbe0f346334e37b7d84481dd3533.tar.bz2
rails-b8ccd0552473fbe0f346334e37b7d84481dd3533.zip
convert strings to lambdas so we can use a consistent interface to the objects in the collection
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb
index bfc2024529..05da50e150 100644
--- a/activesupport/lib/active_support/testing/assertions.rb
+++ b/activesupport/lib/active_support/testing/assertions.rb
@@ -45,17 +45,17 @@ module ActiveSupport
# post :delete, :id => ...
# end
def assert_difference(expression, difference = 1, message = nil, &block)
- b = block.send(:binding)
- exps = Array.wrap(expression)
- before = exps.map { |e| e.respond_to?(:call) ? e.call : eval(e, b) }
+ exps = Array.wrap(expression).map { |e|
+ e.respond_to?(:call) ? e : lambda { eval(e, block.binding) }
+ }
+ before = exps.map { |e| e.call }
yield
exps.each_with_index do |e, i|
error = "#{e.inspect} didn't change by #{difference}"
error = "#{message}.\n#{error}" if message
- actual = e.respond_to?(:call) ? e.call : eval(e, b)
- assert_equal(before[i] + difference, actual, error)
+ assert_equal(before[i] + difference, e.call, error)
end
end