Class: RSpecApi::Matchers::ContentType::Matcher

Inherits:
Headers::Matcher show all
Defined in:
lib/rspec-api/matchers/content_type/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(content_type) ⇒ Matcher

Returns a new instance of Matcher.



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

def initialize(content_type)
  @content_type = content_type
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



7
8
9
# File 'lib/rspec-api/matchers/content_type/matcher.rb', line 7

def content_type
  @content_type
end

Instance Method Details

#descriptionObject



17
18
19
# File 'lib/rspec-api/matchers/content_type/matcher.rb', line 17

def description
  %Q{include 'Content-Type': '#{content_type}'}
end

#matches?(response) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rspec-api/matchers/content_type/matcher.rb', line 13

def matches?(response)
  super && headers.key?('Content-Type') && content_type.match(headers['Content-Type'])
end