diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-02-06 09:18:41 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-02-06 09:18:41 -0800 |
commit | 86dcfdc1fb1c8a3005e69a167e08762b9076c6ea (patch) | |
tree | 307a940149f39c6a869ee44fcf5c2cf76c24fcbf /activesupport/lib/active_support/testing/assertions.rb | |
parent | 86dd2f841d29b326cc480e9c58de63f54799d2c1 (diff) | |
download | rails-86dcfdc1fb1c8a3005e69a167e08762b9076c6ea.tar.gz rails-86dcfdc1fb1c8a3005e69a167e08762b9076c6ea.tar.bz2 rails-86dcfdc1fb1c8a3005e69a167e08762b9076c6ea.zip |
Work around enumerable string deprecation warnings
Diffstat (limited to 'activesupport/lib/active_support/testing/assertions.rb')
-rw-r--r-- | activesupport/lib/active_support/testing/assertions.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index ce2f44efd6..7b19e3f35f 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -32,12 +32,15 @@ module ActiveSupport # 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 |