Sha256: 2fdbc30daf924a4e483707bfbcd65a9fce418a217f92556e4f2a2d7b8d2b71d3

Contents?: true

Size: 972 Bytes

Versions: 23

Compression:

Stored size: 972 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
            [200, {}, ['Set interactions']]
          rescue AlmostDuplicateInteractionError => e
            [500, {}, [e.message]]
          end

        end

        private

        attr_accessor :session
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
pact-mock_service-2.2.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.1.1.pre.alpha.2 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.1.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.0.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-2.0.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-1.2.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-1.1.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-1.0.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.12.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.12.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.11.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.10.2 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.10.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.10.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.9.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.8.2 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.8.1 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.8.0 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.7.2 lib/pact/mock_service/request_handlers/interaction_post.rb
pact-mock_service-0.7.1 lib/pact/mock_service/request_handlers/interaction_post.rb