Sha256: 4afdc99598f372f4886592edaac6c07248508a77cf511fc868bb214bf855e141

Contents?: true

Size: 717 Bytes

Versions: 6

Compression:

Stored size: 717 Bytes

Contents

module APIMatchers
  module Headers
    class Base
      attr_reader :setup

      def initialize(setup)
        @setup = setup
      end

      def matches?(actual)
        @actual = actual

        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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
api_matchers-0.4.0 lib/api_matchers/headers/base.rb
api_matchers-0.3.0 lib/api_matchers/headers/base.rb
api_matchers-0.2.0 lib/api_matchers/headers/base.rb
api_matchers-0.1.1 lib/api_matchers/headers/base.rb
api_matchers-0.1.0 lib/api_matchers/headers/base.rb
api_matchers-0.0.2 lib/api_matchers/headers/base.rb