aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-05-17 20:46:28 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-05-17 20:46:41 -0700
commit1ff53413852db94476d4851e1535669b953c9393 (patch)
treeb4d131e827f759125872135bcb2e43620e29940e
parentfe7e73086240a5bae4dc7cd01f8ec75ad8cddb96 (diff)
downloadrails-1ff53413852db94476d4851e1535669b953c9393.tar.gz
rails-1ff53413852db94476d4851e1535669b953c9393.tar.bz2
rails-1ff53413852db94476d4851e1535669b953c9393.zip
stop swallowing exceptions in assert_queries. Methods that raise an
exception are unlikely to pass this assertion, but since the assertions raise an exception, the original exception is lost.
-rw-r--r--activerecord/lib/active_record/test_case.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/test_case.rb b/activerecord/lib/active_record/test_case.rb
index e9142481a3..1b4c473bfc 100644
--- a/activerecord/lib/active_record/test_case.rb
+++ b/activerecord/lib/active_record/test_case.rb
@@ -35,8 +35,7 @@ module ActiveRecord
def assert_queries(num = 1, options = {})
ignore_none = options.fetch(:ignore_none) { num == :any }
SQLCounter.clear_log
- yield
- ensure
+ x = yield
the_log = ignore_none ? SQLCounter.log_all : SQLCounter.log
if num == :any
assert_operator the_log.size, :>=, 1, "1 or more queries expected, but none were executed."
@@ -44,6 +43,7 @@ module ActiveRecord
mesg = "#{the_log.size} instead of #{num} queries were executed.#{the_log.size == 0 ? '' : "\nQueries:\n#{the_log.join("\n")}"}"
assert_equal num, the_log.size, mesg
end
+ x
end
def assert_no_queries(&block)