Class: Pact::Consumer::VerificationGet

Inherits:
MockServiceAdministrationEndpoint show all
Includes:
RackRequestHelper
Defined in:
lib/pact/consumer/mock_service/verification_get.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 included from RackRequestHelper

#params_hash, #request_as_hash_from

Methods inherited from MockServiceAdministrationEndpoint

#match?

Constructor Details

#initialize(name, logger, interaction_list, log_description) ⇒ VerificationGet

Returns a new instance of VerificationGet.



10
11
12
13
14
# File 'lib/pact/consumer/mock_service/verification_get.rb', line 10

def initialize name, logger, interaction_list, log_description
  super name, logger
  @interaction_list = interaction_list
  @log_description = log_description
end

Instance Attribute Details

#interaction_listObject

Returns the value of attribute interaction_list.



8
9
10
# File 'lib/pact/consumer/mock_service/verification_get.rb', line 8

def interaction_list
  @interaction_list
end

#log_descriptionObject

Returns the value of attribute log_description.



8
9
10
# File 'lib/pact/consumer/mock_service/verification_get.rb', line 8

def log_description
  @log_description
end

Instance Method Details

#example_description(env) ⇒ Object



35
36
37
# File 'lib/pact/consumer/mock_service/verification_get.rb', line 35

def example_description env
  params_hash(env)['example_description']
end

#request_methodObject



20
21
22
# File 'lib/pact/consumer/mock_service/verification_get.rb', line 20

def request_method
  'GET'
end

#request_pathObject



16
17
18
# File 'lib/pact/consumer/mock_service/verification_get.rb', line 16

def request_path
  '/verify'
end

#respond(env) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/pact/consumer/mock_service/verification_get.rb', line 24

def respond env
  if interaction_list.all_matched?
    logger.info "Verifying - interactions matched for example \"#{example_description(env)}\""
    [200, {}, ['Interactions matched']]
  else
    logger.warn "Verifying - actual interactions do not match expected interactions for example \"#{example_description(env)}\". Interaction diffs:"
    logger.ap interaction_list.interaction_diffs, :warn
    [500, {}, ["Actual interactions do not match expected interactions for mock #{name}. See #{log_description} for details."]]
  end
end