Class: Pact::Consumer::InteractionPost

Inherits:
MockServiceAdministrationEndpoint show all
Defined in:
lib/pact/consumer/mock_service/interaction_post.rb

Constant Summary

Constants included from RackRequestHelper

RackRequestHelper::REQUEST_KEYS

Instance Attribute Summary collapse

Attributes inherited from MockServiceAdministrationEndpoint

#logger, #name

Instance Method Summary collapse

Methods inherited from MockServiceAdministrationEndpoint

#match?

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_listObject

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_methodObject



18
19
20
# File 'lib/pact/consumer/mock_service/interaction_post.rb', line 18

def request_method
  'POST'
end

#request_pathObject



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