class QueryMatchers::QueryExecutionMatcher

Public Class Methods

new(expected, counter = QueryCounter.new) click to toggle source
# File lib/query_matchers/query_execution_matcher.rb, line 6
def initialize(expected, counter = QueryCounter.new)
  @expected = expected
  @counter = counter
end

Public Instance Methods

failure_message() click to toggle source
# File lib/query_matchers/query_execution_matcher.rb, line 17
def failure_message
  "expected block to execute #{@expected} SQL queries, " <<
    "but executed #{@counter.query_count}: \n\n" <<
    @counter.queries.map {|q| " - #{q}" }.join("\n") << "\n\n" <<
    "Total queries: #{@counter.query_count}"
end
Also aliased as: failure_message_for_should
failure_message_for_should()

RSpec 2 compatibility:

Alias for: failure_message
failure_message_for_should_not()
failure_message_when_negated() click to toggle source
# File lib/query_matchers/query_execution_matcher.rb, line 24
def failure_message_when_negated
  "expected block not to execute #{@expected} SQL queries, but did"
end
matches?(target) click to toggle source
# File lib/query_matchers/query_execution_matcher.rb, line 11
def matches?(target)
  @counter.execute!(target)

  @counter.query_count == @expected
end
supports_block_expectations?() click to toggle source
# File lib/query_matchers/query_execution_matcher.rb, line 32
def supports_block_expectations?
  true
end