Sha256: 722b12da07603707bb3f4309a1ef8555b32e5fbd3cd903afa7a104322aeabb33
Contents?: true
Size: 652 Bytes
Versions: 20
Compression:
Stored size: 652 Bytes
Contents
class QueryCountMatcher def initialize(num) @expected_count = num end def matches?(block) run(block) if @expected_count.respond_to? :include? @expected_count.include? @count else @count == @expected_count end end def run(block) $query_count = 0 $query_sql = [] block.call ensure @queries = $query_sql.dup @count = $query_count end def performed_queries @queries end def failure_message "expected #{@expected_count} queries, got #{@count}\n#{@queries.join("\n")}" end def negative_failure_message "expected query count not to be #{@expected_count}" end end
Version data entries
20 entries across 20 versions & 2 rubygems