Sha256: da7ff764a42a668dc1e8e34d26cf7f3958d6749bba8c47fa7b7976d7f3d699d2

Contents?: true

Size: 860 Bytes

Versions: 4

Compression:

Stored size: 860 Bytes

Contents

require 'pact/consumer/mock_service/mock_service_administration_endpoint'

module Pact
  module Consumer
    class InteractionPost < MockServiceAdministrationEndpoint

      attr_accessor :interaction_list

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

      def request_path
        '/interactions'
      end

      def request_method
        'POST'
      end

      def respond env
        request_body = env['rack.input'].string
        interaction = Interaction.from_hash(JSON.load(request_body))
        interaction_list.add interaction
        logger.info "Registered expected interaction #{interaction.request.method_and_path}"
        logger.debug JSON.pretty_generate JSON.parse(request_body)
        [200, {}, ['Added interaction']]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact-mock_service-0.2.2 lib/pact/consumer/mock_service/interaction_post.rb
pact-mock_service-0.2.1 lib/pact/consumer/mock_service/interaction_post.rb
pact-mock_service-0.2.0 lib/pact/consumer/mock_service/interaction_post.rb
pact-mock_service-0.1.0 lib/pact/consumer/mock_service/interaction_post.rb