Class: APIMatchers::Headers::Base
- Inherits:
-
Object
- Object
- APIMatchers::Headers::Base
- Defined in:
- lib/api_matchers/headers/base.rb
Instance Attribute Summary collapse
-
#setup ⇒ Object
readonly
Returns the value of attribute setup.
Instance Method Summary collapse
- #content_type_response ⇒ Object
- #expected_content_type ⇒ Object
-
#initialize(setup) ⇒ Base
constructor
A new instance of Base.
- #matches?(actual) ⇒ Boolean
Constructor Details
#initialize(setup) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/api_matchers/headers/base.rb', line 6 def initialize(setup) @setup = setup end |
Instance Attribute Details
#setup ⇒ Object (readonly)
Returns the value of attribute setup.
4 5 6 |
# File 'lib/api_matchers/headers/base.rb', line 4 def setup @setup end |
Instance Method Details
#content_type_response ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/api_matchers/headers/base.rb', line 16 def content_type_response if @setup.header_method.present? and @setup.header_content_type_key.present? headers = @actual.send(@setup.header_method) headers[@setup.header_content_type_key] || headers if headers.present? else @actual end end |
#expected_content_type ⇒ Object
25 26 27 |
# File 'lib/api_matchers/headers/base.rb', line 25 def expected_content_type raise NotImplementedError, "not implemented on #{self}" end |
#matches?(actual) ⇒ Boolean
10 11 12 13 14 |
# File 'lib/api_matchers/headers/base.rb', line 10 def matches?(actual) @actual = actual content_type_response.eql?(expected_content_type) end |