Class: Pact::MockService::RequestHandlers::HandleUnrecognisedInteraction
- Inherits:
-
Object
- Object
- Pact::MockService::RequestHandlers::HandleUnrecognisedInteraction
- Defined in:
- lib/pact/mock_service/request_handlers/interaction_replay.rb
Class Method Summary collapse
- .call(actual_request, candidate_interactions, actual_interactions, logger) ⇒ Object
- .interaction_mismatch(actual_request, candidate_interactions) ⇒ Object
- .log(interaction_mismatch, logger) ⇒ Object
- .response(interaction_mismatch) ⇒ Object
Class Method Details
.call(actual_request, candidate_interactions, actual_interactions, logger) ⇒ Object
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/pact/mock_service/request_handlers/interaction_replay.rb', line 136 def self.call actual_request, candidate_interactions, actual_interactions, logger interaction_mismatch = interaction_mismatch(actual_request, candidate_interactions) if candidate_interactions.any? actual_interactions.register_interaction_mismatch interaction_mismatch else actual_interactions.register_unexpected_request actual_request end log interaction_mismatch, logger response interaction_mismatch end |
.interaction_mismatch(actual_request, candidate_interactions) ⇒ Object
155 156 157 |
# File 'lib/pact/mock_service/request_handlers/interaction_replay.rb', line 155 def self.interaction_mismatch actual_request, candidate_interactions Pact::MockService::Interactions::InteractionMismatch.new(candidate_interactions, actual_request) end |
.log(interaction_mismatch, logger) ⇒ Object
159 160 161 162 163 |
# File 'lib/pact/mock_service/request_handlers/interaction_replay.rb', line 159 def self.log interaction_mismatch, logger logger.error "No matching interaction found for #{interaction_mismatch.actual_request.method_and_path}" logger.error 'Interaction diffs for that route:' logger.error(interaction_mismatch.to_s) end |
.response(interaction_mismatch) ⇒ Object
147 148 149 150 151 152 153 |
# File 'lib/pact/mock_service/request_handlers/interaction_replay.rb', line 147 def self.response interaction_mismatch response = { message: "No interaction found for #{interaction_mismatch.actual_request.method_and_path}", interaction_diffs: interaction_mismatch.to_hash } [500, {'Content-Type' => 'application/json'}, [response.to_json + "\n"]] end |