Class: Pact::MockService::Interactions::InteractionMismatch

Inherits:
Object
  • Object
show all
Defined in:
lib/pact/mock_service/interactions/interaction_mismatch.rb

Overview

expected interactions where the methods and paths match the actual request. This is used to display a helpful message to the user when a request comes in that doesn’t match any of the expected interactions.

Defined Under Namespace

Classes: CandidateDiff

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(candidate_interactions, actual_request) ⇒ InteractionMismatch

Assumes the method and path matches…



14
15
16
17
18
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 14

def initialize candidate_interactions, actual_request
  @candidate_interactions = candidate_interactions
  @actual_request = actual_request
  @candiate_diffs = candidate_interactions.collect{ | candidate_interaction| CandidateDiff.new(candidate_interaction, actual_request)}
end

Instance Attribute Details

#actual_requestObject

Returns the value of attribute actual_request.



10
11
12
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 10

def actual_request
  @actual_request
end

#candidate_interactionsObject

Returns the value of attribute candidate_interactions.



10
11
12
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 10

def candidate_interactions
  @candidate_interactions
end

Instance Method Details

#short_summaryObject



28
29
30
31
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 28

def short_summary
  mismatched_attributes = candiate_diffs.collect(&:mismatched_attributes).flatten.uniq.join(", ").reverse.sub(",", "dna ").reverse #OMG what a hack!
  actual_request.method_and_path + " (request #{mismatched_attributes} did not match)"
end

#to_hashObject



20
21
22
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 20

def to_hash
  candiate_diffs.collect(&:to_hash)
end

#to_sObject



24
25
26
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 24

def to_s
  candiate_diffs.collect(&:to_s).join("\n")
end