Class: QueryMatchers::QueryExecutionMatcher
- Inherits:
-
Object
- Object
- QueryMatchers::QueryExecutionMatcher
- Defined in:
- lib/query_matchers/query_execution_matcher.rb
Instance Method Summary collapse
- #failure_message ⇒ Object (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ Object (also: #failure_message_for_should_not)
-
#initialize(expected, counter = QueryCounter.new) ⇒ QueryExecutionMatcher
constructor
A new instance of QueryExecutionMatcher.
- #matches?(target) ⇒ Boolean
- #supports_block_expectations? ⇒ Boolean
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 Also known as: failure_message_for_should
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 |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not
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 |
#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 |
#supports_block_expectations? ⇒ Boolean
32 33 34 |
# File 'lib/query_matchers/query_execution_matcher.rb', line 32 def supports_block_expectations? true end |