Sha256: e062c82c014040df3543943a1da5086b01a0f2d62ffcb12d96de2eb3c9cae44d

Contents?: true

Size: 968 Bytes

Versions: 17

Compression:

Stored size: 968 Bytes

Contents

require 'pact/mock_service/request_handlers/base_administration_request_handler'
require 'pact/mock_service/session'

module Pact
  module MockService
    module RequestHandlers
      class InteractionPost < BaseAdministrationRequestHandler

        def initialize name, logger, session
          super name, logger
          @session = session
        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)) # Load creates the Pact::XXX classes

          begin
            session.add_expected_interaction interaction
            text_response 'Registered interactions'
          rescue ::Pact::Error => e
            text_response e.message, 500
          end

        end

        private

        attr_accessor :session
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pact-mock_service-2.9.3 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.9.2 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.9.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.9.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.8.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.8.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.7.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.7.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.6.4 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.6.3 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.6.2 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.6.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.5.4 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.5.3 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.5.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.4.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.3.0 lib/pact/mock_service/request_handlers/interaction_post.rb