Sha256: a85cd171c3f1d175149cf41281b2407f4b9cee28b93e50cf0f889bae93ab8734

Contents?: true

Size: 947 Bytes

Versions: 6

Compression:

Stored size: 947 Bytes

Contents

require 'fitting/response'
require 'fitting/storage/responses'
require 'fitting/storage/documentation'

module Fitting
  module Matchers
    class Response
      def matches?(response)
        @response = Fitting::Response.new(
          response,
          Fitting::Storage::Documentation.tomogram
        )
        Fitting::Storage::Responses.push(@response)
        @response.valid?
      end

      def ===(other)
        matches?(other)
      end

      def failure_message
        unless @response.documented?
          return "response not documented\n"\
                 "got: #{@response.real_request_with_status}"
        end

        unless @response.valid?
          "response does not conform to json-schema\n"\
          "schemas: \n#{@response.expected}\n\n"\
          "got: #{@response.got}\n\n"\
          "errors: \n#{@response.diff}\n"
        end
      end
    end

    def match_response
      Response.new
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fitting-1.5.0 lib/fitting/matchers/response_matcher.rb
fitting-1.4.0 lib/fitting/matchers/response_matcher.rb
fitting-1.3.1 lib/fitting/matchers/response_matcher.rb
fitting-1.3.0 lib/fitting/matchers/response_matcher.rb
fitting-1.2.0 lib/fitting/matchers/response_matcher.rb
fitting-1.1.0 lib/fitting/matchers/response_matcher.rb