Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

convert strings to lambdas so we can use a consistent interface to th…

…e objects in the collection
  • Loading branch information...
commit b8ccd0552473fbe0f346334e37b7d84481dd3533 1 parent 23eb81a
@tenderlove tenderlove authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 activesupport/lib/active_support/testing/assertions.rb
View
10 activesupport/lib/active_support/testing/assertions.rb
@@ -45,17 +45,17 @@ module Assertions
# 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
Please sign in to comment.
Something went wrong with that request. Please try again.