Sha256: 2805afd3d8066953e4903654c801b1c9eff27b6c708c4b179332192f57f95376

Contents?: true

Size: 632 Bytes

Versions: 2

Compression:

Stored size: 632 Bytes

Contents

# -*- encoding : utf-8 -*-
module Pacto
  module Actors
    class JSONGenerator < Actor
      def build_request(contract, values = {})
        data = contract.request.to_hash
        data['uri'] = contract.request.uri(values)
        data['body'] = JSON::Generator.generate(data['schema']) if data['schema']
        data['method'] = contract.request.http_method
        Pacto::PactoRequest.new(data)
      end

      def build_response(contract, _values = {})
        data = contract.response.to_hash
        data['body'] = JSON::Generator.generate(data['schema'])
        Pacto::PactoResponse.new(data)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pacto-0.4.0.rc3 lib/pacto/actors/json_generator.rb
pacto-0.4.0.rc2 lib/pacto/actors/json_generator.rb