Class: Pact::MockService::RequestHandlers::InteractionsPut
- Inherits:
-
BaseAdministrationRequestHandler
- Object
- BaseRequestHandler
- BaseAdministrationRequestHandler
- Pact::MockService::RequestHandlers::InteractionsPut
- Defined in:
- lib/pact/mock_service/request_handlers/interactions_put.rb
Constant Summary
Constants inherited from BaseRequestHandler
BaseRequestHandler::NOT_FOUND_RESPONSE
Constants included from Consumer::RackRequestHelper
Consumer::RackRequestHelper::REQUEST_KEYS
Instance Attribute Summary
Attributes inherited from BaseAdministrationRequestHandler
Instance Method Summary collapse
-
#initialize(name, logger, session, pact_specification_version) ⇒ InteractionsPut
constructor
A new instance of InteractionsPut.
- #request_method ⇒ Object
- #request_path ⇒ Object
- #respond(env) ⇒ Object
Methods inherited from BaseAdministrationRequestHandler
#has_mock_service_header?, #match?, #method_matches?, #path_matches?
Methods inherited from BaseRequestHandler
#call, #json_response, #match?, #text_response
Methods included from Consumer::RackRequestHelper
#params_hash, #request_as_hash_from
Constructor Details
#initialize(name, logger, session, pact_specification_version) ⇒ InteractionsPut
Returns a new instance of InteractionsPut.
11 12 13 14 15 |
# File 'lib/pact/mock_service/request_handlers/interactions_put.rb', line 11 def initialize name, logger, session, pact_specification_version super name, logger @session = session @pact_specification_version = pact_specification_version end |
Instance Method Details
#request_method ⇒ Object
21 22 23 |
# File 'lib/pact/mock_service/request_handlers/interactions_put.rb', line 21 def request_method 'PUT' end |
#request_path ⇒ Object
17 18 19 |
# File 'lib/pact/mock_service/request_handlers/interactions_put.rb', line 17 def request_path '/interactions' end |
#respond(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pact/mock_service/request_handlers/interactions_put.rb', line 25 def respond env request_body = JSON.load(env['rack.input'].string) = { pact_specification_version: pact_specification_version } interactions = request_body['interactions'].collect { | hash | Interaction.from_hash(hash, ) } begin session.set_expected_interactions interactions text_response('Registered interactions') rescue Pact::Error => e text_response(e., 500) end end |