Class: RSpecApi::Matchers::Filter::Matcher
- Inherits:
-
Collection::Matcher
- Object
- Response::Matcher
- Json::Matcher
- Collection::Matcher
- RSpecApi::Matchers::Filter::Matcher
- Defined in:
- lib/rspec-api/matchers/filter/matcher.rb
Instance Attribute Summary collapse
-
#compare_with ⇒ Object
Returns the value of attribute compare_with.
-
#field ⇒ Object
Returns the value of attribute field.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Response::Matcher
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(options = {}) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(response) ⇒ Boolean
Methods inherited from Response::Matcher
#failure_message_for_should, #failure_message_for_should_not
Constructor Details
#initialize(options = {}) ⇒ Matcher
Returns a new instance of Matcher.
9 10 11 12 13 |
# File 'lib/rspec-api/matchers/filter/matcher.rb', line 9 def initialize( = {}) @field = [:by] @value = [:value] @compare_with = .fetch :compare_with, :== end |
Instance Attribute Details
#compare_with ⇒ Object
Returns the value of attribute compare_with.
7 8 9 |
# File 'lib/rspec-api/matchers/filter/matcher.rb', line 7 def compare_with @compare_with end |
#field ⇒ Object
Returns the value of attribute field.
7 8 9 |
# File 'lib/rspec-api/matchers/filter/matcher.rb', line 7 def field @field end |
#value ⇒ Object
Returns the value of attribute value.
7 8 9 |
# File 'lib/rspec-api/matchers/filter/matcher.rb', line 7 def value @value end |
Instance Method Details
#description ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rspec-api/matchers/filter/matcher.rb', line 19 def description if field %Q(be filtered by #{field}#{compare_with}#{value}) else %Q(be filtered) end end |
#matches?(response) ⇒ Boolean
15 16 17 |
# File 'lib/rspec-api/matchers/filter/matcher.rb', line 15 def matches?(response) super && all_objects_have_field? && has_one_object? && is_filtered? end |