Class: Pact::Consumer::InteractionPost
- Inherits:
-
MockServiceAdministrationEndpoint
- Object
- MockServiceAdministrationEndpoint
- Pact::Consumer::InteractionPost
- Defined in:
- lib/pact/consumer/mock_service/interaction_post.rb
Constant Summary
Constants included from RackRequestHelper
RackRequestHelper::REQUEST_KEYS
Instance Attribute Summary collapse
-
#interaction_list ⇒ Object
Returns the value of attribute interaction_list.
Attributes inherited from MockServiceAdministrationEndpoint
Instance Method Summary collapse
-
#initialize(name, logger, interaction_list) ⇒ InteractionPost
constructor
A new instance of InteractionPost.
- #request_method ⇒ Object
- #request_path ⇒ Object
- #respond(env) ⇒ Object
Methods inherited from MockServiceAdministrationEndpoint
Methods included from RackRequestHelper
#params_hash, #request_as_hash_from
Constructor Details
#initialize(name, logger, interaction_list) ⇒ InteractionPost
Returns a new instance of InteractionPost.
9 10 11 12 |
# File 'lib/pact/consumer/mock_service/interaction_post.rb', line 9 def initialize name, logger, interaction_list super name, logger @interaction_list = interaction_list end |
Instance Attribute Details
#interaction_list ⇒ Object
Returns the value of attribute interaction_list.
7 8 9 |
# File 'lib/pact/consumer/mock_service/interaction_post.rb', line 7 def interaction_list @interaction_list end |
Instance Method Details
#request_method ⇒ Object
18 19 20 |
# File 'lib/pact/consumer/mock_service/interaction_post.rb', line 18 def request_method 'POST' end |
#request_path ⇒ Object
14 15 16 |
# File 'lib/pact/consumer/mock_service/interaction_post.rb', line 14 def request_path '/interactions' end |
#respond(env) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/pact/consumer/mock_service/interaction_post.rb', line 22 def respond env interaction = Interaction.from_hash(JSON.load(env['rack.input'].string)) interaction_list.add interaction logger.info "Registered expected interaction #{interaction.request.method_and_path} for #{name}" logger.ap interaction.as_json [200, {}, ['Added interactions']] end |