Class: RSpec::Sql::QueryMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/sql/query_matcher.rb

Overview

Compares expectations with actual queries.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#expectedObject (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

#actualObject



23
24
25
# File 'lib/rspec/sql/query_matcher.rb', line 23

def actual
  @actual ||= actual_compared_to_expected
end

#matches?Boolean

Returns:

  • (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