diff options
author | Olli Jokinen <olli.jokinen@enemy.fi> | 2011-12-01 15:32:59 +0200 |
---|---|---|
committer | Olli Jokinen <olli.jokinen@enemy.fi> | 2011-12-01 15:32:59 +0200 |
commit | b4e1903d23a760028d58bc3bb20a1d491bfd4a4b (patch) | |
tree | a40bdce1bd4800124ab6eaed2a6be017bf9cfd3d /activesupport/lib/active_support/testing/assertions.rb | |
parent | fae9ad9c712decef70b379f5aa1faa0149902831 (diff) | |
parent | 1e51cd957e3c90f4be35f1f0c4c380d8f7d40d66 (diff) | |
download | rails-b4e1903d23a760028d58bc3bb20a1d491bfd4a4b.tar.gz rails-b4e1903d23a760028d58bc3bb20a1d491bfd4a4b.tar.bz2 rails-b4e1903d23a760028d58bc3bb20a1d491bfd4a4b.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'activesupport/lib/active_support/testing/assertions.rb')
-rw-r--r-- | activesupport/lib/active_support/testing/assertions.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index 3864b1f5a6..f3629ada5b 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -45,15 +45,17 @@ module ActiveSupport # post :delete, :id => ... # end def assert_difference(expression, difference = 1, message = nil, &block) - exps = Array.wrap(expression).map { |e| + expressions = Array.wrap expression + + exps = expressions.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}" + expressions.zip(exps).each_with_index do |(code, e), i| + error = "#{code.inspect} didn't change by #{difference}" error = "#{message}.\n#{error}" if message assert_equal(before[i] + difference, e.call, error) end |