class ActiveRecord::TestCase

def assert_queries(num = 1, options = {})

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