Class: RSpecApi::Matchers::Sort::Matcher
- Inherits:
-
Collection::Matcher
- Object
- Response::Matcher
- Json::Matcher
- Collection::Matcher
- RSpecApi::Matchers::Sort::Matcher
- Defined in:
- lib/rspec-api/matchers/sort/matcher.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#verse ⇒ Object
Returns the value of attribute verse.
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 |
# File 'lib/rspec-api/matchers/sort/matcher.rb', line 9 def initialize( = {}) @field = [:by] @verse = [:verse] end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
7 8 9 |
# File 'lib/rspec-api/matchers/sort/matcher.rb', line 7 def field @field end |
#verse ⇒ Object
Returns the value of attribute verse.
7 8 9 |
# File 'lib/rspec-api/matchers/sort/matcher.rb', line 7 def verse @verse end |
Instance Method Details
#description ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/rspec-api/matchers/sort/matcher.rb', line 18 def description if field %Q(be sorted by #{reverse? ? 'descending' : 'ascending'} #{field}) else %Q(be sorted) end end |
#matches?(response) ⇒ Boolean
14 15 16 |
# File 'lib/rspec-api/matchers/sort/matcher.rb', line 14 def matches?(response) super && all_objects_have_field? && has_two_objects? && is_sorted? end |