Flowdock
method

assert_sql

Importance_0
Ruby on Rails latest stable (v4.0.2) - 0 notes - Class: ActiveRecord::TestCase
assert_sql(*patterns_to_match) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/test_case.rb, line 23
    def assert_sql(*patterns_to_match)
      SQLCounter.clear_log
      yield
      SQLCounter.log_all
    ensure
      failed_patterns = []
      patterns_to_match.each do |pattern|
        failed_patterns << pattern unless SQLCounter.log_all.any?{ |sql| pattern === sql }
      end
      assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map{ |p| p.inspect }.join(', ')} not found.#{SQLCounter.log.size == 0 ? '' : "\nQueries:\n#{SQLCounter.log.join("\n")}"}"
    end
Register or log in to add new notes.