diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-02-06 17:01:34 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-02-06 17:01:34 -0800 |
commit | 24ac1d6bdc860d234e70dd4cd4713bd13ac9d40d (patch) | |
tree | 144087fb520dcbce5d80f2e8eb4c0713ed74adfa /activesupport | |
parent | 49afe58d0b25a86cb47386071001ab7108bc5e24 (diff) | |
download | rails-24ac1d6bdc860d234e70dd4cd4713bd13ac9d40d.tar.gz rails-24ac1d6bdc860d234e70dd4cd4713bd13ac9d40d.tar.bz2 rails-24ac1d6bdc860d234e70dd4cd4713bd13ac9d40d.zip |
Oops, don't yield per expression
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/testing/assertions.rb | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index 771c116dff..ca51adba1e 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -32,17 +32,16 @@ module ActiveSupport # post :delete, :id => ... # end def assert_difference(expression, difference = 1, message = nil, &block) - case expression - when String - before = eval(expression, block.send(:binding)) - yield - error = "#{expression.inspect} didn't change by #{difference}" + b = block.send(:binding) + exps = Array.wrap(expression) + before = exps.map { |e| eval(e, b) } + + yield + + exps.each_with_index do |e, i| + error = "#{e.inspect} didn't change by #{difference}" error = "#{message}.\n#{error}" if message - assert_equal(before + difference, eval(expression, block.send(:binding)), error) - when Enumerable - expression.each { |e| assert_difference(e, difference, message, &block) } - else - raise ArgumentError, "Unrecognized expression: #{expression.inspect}" + assert_equal(before[i] + difference, eval(e, b), error) end end |