method
assert_queries
v4.0.2 -
Show latest stable
- Class:
ActiveRecord::TestCase
assert_queries(num = 1, options = {})public
No documentation available.
# File activerecord/lib/active_record/test_case.rb, line 35
def assert_queries(num = 1, options = {})
ignore_none = options.fetch(:ignore_none) { num == :any }
SQLCounter.clear_log
yield
ensure
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."
else
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
end