Sha256: daba27675368dcec544e2527adaa361dcd66ab07419676cdb681b287ea9d22fd

Contents?: true

Size: 1.17 KB

Versions: 27

Compression:

Stored size: 1.17 KB

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, pact_specification_version
          super name, logger
          @session = session
          @pact_specification_version = pact_specification_version
        end

        def request_path
          '/interactions'
        end

        def request_method
          'POST'
        end

        def respond env
          request_body = env['rack.input'].string
          parsing_options = { pact_specification_version: pact_specification_version }
          interaction = Interaction.from_hash(JSON.load(request_body), parsing_options) # 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, :pact_specification_version
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
pact-mock_service-3.11.2 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.11.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.11.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.10.0 lib/pact/mock_service/request_handlers/interaction_post.rb
hs-pact-mock_service-3.9.2 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.9.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.9.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.8.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.7.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.6.2 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.6.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.6.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.5.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.4.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.3.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.3.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.2.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.2.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.1.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-3.1.0 lib/pact/mock_service/request_handlers/interaction_post.rb