提交 1ff53413 编写于 作者: A Aaron Patterson

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.
上级 fe7e7308
......@@ -35,8 +35,7 @@ def assert_sql(*patterns_to_match)
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 @@ def assert_queries(num = 1, options = {})
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册