Class: RSpecApi::Matchers::Attributes::Matcher

Inherits:
Json::Matcher show all
Defined in:
lib/rspec-api/matchers/attributes/matcher.rb

Instance Attribute Summary collapse

Attributes inherited from Response::Matcher

#response

Instance Method Summary collapse

Methods inherited from Response::Matcher

#failure_message_for_should, #failure_message_for_should_not

Constructor Details

#initialize(*attributes, &block) ⇒ Matcher

Returns a new instance of Matcher.



11
12
13
# File 'lib/rspec-api/matchers/attributes/matcher.rb', line 11

def initialize(*attributes, &block)
  @attributes = to_hash attributes
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



9
10
11
# File 'lib/rspec-api/matchers/attributes/matcher.rb', line 9

def attributes
  @attributes
end

Instance Method Details

#descriptionObject



19
20
21
22
23
24
25
# File 'lib/rspec-api/matchers/attributes/matcher.rb', line 19

def description
  if attributes.any?
    %Q(have attributes #{attributes})
  else
    %Q(have attributes)
  end
end

#matches?(response) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rspec-api/matchers/attributes/matcher.rb', line 15

def matches?(response)
  super && has_attributes?(json, attributes)
end