Class: Dumbo::Matchers::QueryMatcher
- Inherits:
-
RSpec::Matchers::BuiltIn::ContainExactly
- Object
- RSpec::Matchers::BuiltIn::ContainExactly
- Dumbo::Matchers::QueryMatcher
- Defined in:
- lib/dumbo/test/matchers.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #convert_actual ⇒ Object
- #convert_expected ⇒ Object
- #failure_message_for_should ⇒ Object
-
#initialize(expected = UNDEFINED, options = {}) ⇒ QueryMatcher
constructor
A new instance of QueryMatcher.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(expected = UNDEFINED, options = {}) ⇒ QueryMatcher
Returns a new instance of QueryMatcher.
31 32 33 34 |
# File 'lib/dumbo/test/matchers.rb', line 31 def initialize(expected = UNDEFINED, ={}) @expected = expected unless UNDEFINED.equal?(expected) @options = end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
29 30 31 |
# File 'lib/dumbo/test/matchers.rb', line 29 def actual @actual end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
29 30 31 |
# File 'lib/dumbo/test/matchers.rb', line 29 def expected @expected end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
29 30 31 |
# File 'lib/dumbo/test/matchers.rb', line 29 def @options end |
Instance Method Details
#convert_actual ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/dumbo/test/matchers.rb', line 60 def convert_actual @actual = if [:header] [actual.columns] + actual.rows else case actual.rows.size when 0 [] when 1 actual.rows.first else actual.rows end end end |
#convert_expected ⇒ Object
56 57 58 |
# File 'lib/dumbo/test/matchers.rb', line 56 def convert_expected @expected = [expected] unless expected.is_a?(Array) end |
#failure_message_for_should ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dumbo/test/matchers.rb', line 44 def if @missing_items.empty? && @extra_items.empty? = "actual collection is in the wrong order\n" += "expected collection contained: #{expected.inspect}\n" += "actual collection contained: #{actual.inspect}\n" else super end end |
#matches?(actual) ⇒ Boolean
36 37 38 39 40 41 42 |
# File 'lib/dumbo/test/matchers.rb', line 36 def matches?(actual) @actual = actual convert_actual convert_expected match = match(expected, self.actual) [:ordered] ? expected == self.actual : match end |