Sha256: 041bb6e9394c62c88d926c6c6ea742b63ea2afa72a79e898977fb449f21f6115

Contents?: true

Size: 784 Bytes

Versions: 5

Compression:

Stored size: 784 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

5 entries across 5 versions & 1 rubygems

Version Path
api_matchers-0.6.2 lib/api_matchers/http_status_code/base.rb
api_matchers-0.6.1 lib/api_matchers/http_status_code/base.rb
api_matchers-0.6.0 lib/api_matchers/http_status_code/base.rb
api_matchers-0.5.1 lib/api_matchers/http_status_code/base.rb
api_matchers-0.5.0 lib/api_matchers/http_status_code/base.rb