Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Work around enumerable string deprecation warnings

  • Loading branch information...
commit 86dcfdc1fb1c8a3005e69a167e08762b9076c6ea 1 parent 86dd2f8
@jeremy jeremy authored
Showing with 9 additions and 6 deletions.
  1. +9 −6 activesupport/lib/active_support/testing/assertions.rb
View
15 activesupport/lib/active_support/testing/assertions.rb
@@ -32,12 +32,15 @@ module Assertions
# post :delete, :id => ...
# end
def assert_difference(expressions, difference = 1, message = nil, &block)
- expression_evaluations = Array(expressions).collect{ |expression| lambda { eval(expression, block.send(:binding)) } }
-
- original_values = expression_evaluations.inject([]) { |memo, expression| memo << expression.call }
- yield
- expression_evaluations.each_with_index do |expression, i|
- assert_equal original_values[i] + difference, expression.call, message
+ case expressions
+ when String
+ before = eval(expressions, block.send(:binding))
+ yield
+ assert_equal(before + difference, eval(expressions, block.send(:binding)), message)
+ when Enumerable
+ expressions.each { |e| assert_difference(e, difference, message, &block) }
+ else
+ raise ArgumentError, "Unrecognized expression: #{expressions.inspect}"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.