Sha256: b77e81f3fa420969965201cf794d3f2e81fa6356af902780eb23e4730bb39938

Contents?: true

Size: 783 Bytes

Versions: 7

Compression:

Stored size: 783 Bytes

Contents

module APIMatchers
  module HTTPStatusCode
    class Base
      attr_reader :setup

      def initialize(setup)
        @setup = setup
      end

      # Matches the actual with the expected http status code
      #
      def matches?(actual)
        @http_status_code = find_http_status_code(actual)
        @http_status_code.equal?(expected_status_code)
      end

      def expected_status_code
        raise NotImplementedError, "not implemented on #{self}"
      end

      # If have some configuration about the method to call on actual that method will be called.
      #
      def find_http_status_code(actual)
        if @setup.http_status_method.present?
          actual.send(@setup.http_status_method)
        else
          actual
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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