Class: QueryMatchers::QueryExecutionMatcher
- Inherits:
-
Object
- Object
- QueryMatchers::QueryExecutionMatcher
- Defined in:
- lib/query_matchers/query_execution_matcher.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(expected, counter = QueryCounter.new) ⇒ QueryExecutionMatcher
constructor
A new instance of QueryExecutionMatcher.
- #matches?(target) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected, counter = QueryCounter.new) ⇒ QueryExecutionMatcher
Returns a new instance of QueryExecutionMatcher.
6 7 8 9 |
# File 'lib/query_matchers/query_execution_matcher.rb', line 6 def initialize(expected, counter = QueryCounter.new) @expected = expected @counter = counter end |
Instance Method Details
#failure_message ⇒ Object
17 18 19 20 21 22 |
# File 'lib/query_matchers/query_execution_matcher.rb', line 17 def "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 |
#matches?(target) ⇒ Boolean
11 12 13 14 15 |
# File 'lib/query_matchers/query_execution_matcher.rb', line 11 def matches?(target) @counter.execute!(target) @counter.query_count == @expected end |
#negative_failure_message ⇒ Object
24 25 26 |
# File 'lib/query_matchers/query_execution_matcher.rb', line 24 def "expected block not to execute #{@expected} SQL queries, but did" end |