Sha256: 4a680cb26936d729a68c9304c5d044f3af350bb279e52a47dbddc5fb650d3cd7

Contents?: true

Size: 625 Bytes

Versions: 1

Compression:

Stored size: 625 Bytes

Contents

module Pacto
  module Validators
    class ResponseBodyValidator < BodyValidator
      def initialize(app)
        @app = app
      end

      def self.section_name
        'response'
      end

      def self.subschema(contract)
        contract.response.schema
      end

      def call(env)
        if env[:validation_results].empty? # skip body validation if we already have other errors
          actual_body = env[:actual_response]
          errors = self.class.validate(env[:contract], actual_body)
          env[:validation_results].concat errors.compact
        end
        @app.call env
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pacto-0.3.1 lib/pacto/validators/response_body_validator.rb