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.
65 66 67 68 |
# File 'lib/dumbo/test/matchers.rb', line 65 def initialize(expected = UNDEFINED, ={}) @expected = expected unless UNDEFINED.equal?(expected) @options = end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
63 64 65 |
# File 'lib/dumbo/test/matchers.rb', line 63 def actual @actual end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
63 64 65 |
# File 'lib/dumbo/test/matchers.rb', line 63 def expected @expected end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
63 64 65 |
# File 'lib/dumbo/test/matchers.rb', line 63 def @options end |
Instance Method Details
#convert_actual ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/dumbo/test/matchers.rb', line 95 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
91 92 93 |
# File 'lib/dumbo/test/matchers.rb', line 91 def convert_expected @expected = [expected] unless expected.is_a?(Array) end |
#failure_message_for_should ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/dumbo/test/matchers.rb', line 79 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
70 71 72 73 74 75 76 77 |
# File 'lib/dumbo/test/matchers.rb', line 70 def matches?(actual) raise actual if actual.kind_of?(Exception) @actual = actual convert_actual convert_expected match = match(expected, self.actual) [:ordered] ? expected == self.actual : match end |