Class: Pact::MockService::RequestHandlers::InteractionPost
- Inherits:
-
BaseAdministrationRequestHandler
- Object
- BaseRequestHandler
- BaseAdministrationRequestHandler
- Pact::MockService::RequestHandlers::InteractionPost
- Defined in:
- lib/pact/mock_service/request_handlers/interaction_post.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) ⇒ InteractionPost
constructor
A new instance of InteractionPost.
- #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) ⇒ InteractionPost
Returns a new instance of InteractionPost.
9 10 11 12 13 |
# File 'lib/pact/mock_service/request_handlers/interaction_post.rb', line 9 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
19 20 21 |
# File 'lib/pact/mock_service/request_handlers/interaction_post.rb', line 19 def request_method 'POST' end |
#request_path ⇒ Object
15 16 17 |
# File 'lib/pact/mock_service/request_handlers/interaction_post.rb', line 15 def request_path '/interactions' end |
#respond(env) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pact/mock_service/request_handlers/interaction_post.rb', line 23 def respond env request_body = env['rack.input'].string = { pact_specification_version: pact_specification_version } 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., 500 end end |