Class: RSpec::Sql::QueryMatcher
- Inherits:
-
Object
- Object
- RSpec::Sql::QueryMatcher
- Defined in:
- lib/rspec/sql/query_matcher.rb
Overview
Compares expectations with actual queries.
Instance Attribute Summary collapse
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
Instance Method Summary collapse
- #actual ⇒ Object
-
#initialize(queries, expected) ⇒ QueryMatcher
constructor
A new instance of QueryMatcher.
- #matches? ⇒ Boolean
Constructor Details
#initialize(queries, expected) ⇒ QueryMatcher
Returns a new instance of QueryMatcher.
11 12 13 14 |
# File 'lib/rspec/sql/query_matcher.rb', line 11 def initialize(queries, expected) @queries = queries @expected = sanitize_number(expected) end |
Instance Attribute Details
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
9 10 11 |
# File 'lib/rspec/sql/query_matcher.rb', line 9 def expected @expected end |
Instance Method Details
#actual ⇒ Object
23 24 25 |
# File 'lib/rspec/sql/query_matcher.rb', line 23 def actual @actual ||= actual_compared_to_expected end |
#matches? ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/rspec/sql/query_matcher.rb', line 16 def matches? # Simple presence validation. return !@queries.empty? if expected.nil? actual == expected end |