Class: Pact::MockService::Interactions::Verification

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

Instance Method Summary collapse

Constructor Details

#initialize(expected_interactions, actual_interactions) ⇒ Verification

Returns a new instance of Verification.



6
7
8
9
# File 'lib/pact/mock_service/interactions/verification.rb', line 6

def initialize expected_interactions, actual_interactions
  @expected_interactions = expected_interactions
  @actual_interactions = actual_interactions
end

Instance Method Details

#all_matched?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/pact/mock_service/interactions/verification.rb', line 11

def all_matched?
  interaction_diffs.empty?
end

#interaction_diffsObject



15
16
17
18
19
20
21
22
23
# File 'lib/pact/mock_service/interactions/verification.rb', line 15

def interaction_diffs
  {
    :missing_interactions => missing_interactions_summaries,
    :interaction_mismatches => interaction_mismatches_summaries,
    :unexpected_requests => unexpected_requests_summaries
  }.each_with_object({}) do | (key, value), hash |
    hash[key] = value if value.any?
  end
end

#interaction_mismatchesObject



41
42
43
# File 'lib/pact/mock_service/interactions/verification.rb', line 41

def interaction_mismatches
  actual_interactions.interaction_mismatches
end

#interaction_mismatches_summariesObject



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

def interaction_mismatches_summaries
  actual_interactions.interaction_mismatches.collect(&:short_summary)
end

#missing_interactionsObject



37
38
39
# File 'lib/pact/mock_service/interactions/verification.rb', line 37

def missing_interactions
  expected_interactions - actual_interactions.matched_interactions - @actual_interactions.interaction_mismatches.collect(&:candidate_interactions).flatten
end

#missing_interactions_summariesObject



25
26
27
# File 'lib/pact/mock_service/interactions/verification.rb', line 25

def missing_interactions_summaries
  missing_interactions.collect(&:request).collect(&:method_and_path)
end

#unexpected_requests_summariesObject



33
34
35
# File 'lib/pact/mock_service/interactions/verification.rb', line 33

def unexpected_requests_summaries
  actual_interactions.unexpected_requests.collect(&:method_and_path)
end