Sha256: 2549c42971a8b7680f5270aa7d151801eab1338e9757a2de09ac4d7c37859b34

Contents?: true

Size: 774 Bytes

Versions: 2

Compression:

Stored size: 774 Bytes

Contents

module Pacto
  class ContractValidator
    class << self
      def validate(contract, request, response, opts)
        env = {
          :contract => contract,
          :actual_request => request,
          :actual_response => response,
          :validation_results => []
        }
        validation_stack(opts).call env
        env[:validation_results].compact
      end

      private

      def validation_stack(opts)
        Middleware::Builder.new do
          use Pacto::Validators::RequestBodyValidator
          unless opts[:body_only]
            use Pacto::Validators::ResponseStatusValidator
            use Pacto::Validators::ResponseHeaderValidator
          end
          use Pacto::Validators::ResponseBodyValidator
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pacto-0.3.1 lib/pacto/contract_validator.rb
pacto-0.3.0 lib/pacto/contract_validator.rb