lib/api_matchers/headers/base.rb in api_matchers-0.0.1 vs lib/api_matchers/headers/base.rb in api_matchers-0.0.2

- old
+ new

@@ -1,10 +1,28 @@ module APIMatchers module Headers class Base + attr_reader :setup + + def initialize(setup) + @setup = setup + end + def matches?(actual) @actual = actual - actual.eql?(expected_content_type) + + content_type_response.eql?(expected_content_type) + end + + def content_type_response + if @setup.header_method.present? and @setup.header_content_type_key.present? + headers = @actual.send(@setup.header_method) + if headers.present? + headers[@setup.header_content_type_key] || headers + end + else + @actual + end end def expected_content_type raise NotImplementedError, "not implemented on #{self}" end \ No newline at end of file