Sha256: 259ba1ba20055bc4fa4f1ec054d298193353f4ac03317e1b91de0a55dfc27f85

Contents?: true

Size: 960 Bytes

Versions: 11

Compression:

Stored size: 960 Bytes

Contents

require 'pact/consumer/mock_service/mock_service_administration_endpoint'
require 'pact/consumer_contract/consumer_contract_writer'

module Pact
  module Consumer
    class PactPost < MockServiceAdministrationEndpoint

      attr_accessor :consumer_contract, :interactions

      def initialize name, logger, interactions
        super name, logger
        @interactions = interactions
      end

      def request_path
        '/pact'
      end

      def request_method
        'POST'
      end

      def respond env
        consumer_contract_details = JSON.parse(env['rack.input'].string, symbolize_names: true)
        logger.info "Writing pact with details #{consumer_contract_details}"
        consumer_contract_writer = ConsumerContractWriter.new(consumer_contract_details.merge(interactions: interactions), logger)
        json = consumer_contract_writer.write

        [200, {'Content-Type' =>'application/json'}, [json]]
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
pact-mock_service-0.2.2 lib/pact/consumer/mock_service/pact_post.rb
pact-mock_service-0.2.1 lib/pact/consumer/mock_service/pact_post.rb
pact-mock_service-0.2.0 lib/pact/consumer/mock_service/pact_post.rb
pact-mock_service-0.1.0 lib/pact/consumer/mock_service/pact_post.rb
pact-mock_service-0.0.1 lib/pact/consumer/mock_service/pact_post.rb
pact-1.3.3 lib/pact/consumer/mock_service/pact_post.rb
pact-1.3.2 lib/pact/consumer/mock_service/pact_post.rb
pact-1.3.1 lib/pact/consumer/mock_service/pact_post.rb
pact-1.3.0 lib/pact/consumer/mock_service/pact_post.rb
pact-1.2.1.rc2 lib/pact/consumer/mock_service/pact_post.rb
pact-1.2.1.rc1 lib/pact/consumer/mock_service/pact_post.rb