Module: PactBroker::Client::MergePacts

Extended by:
MergePacts
Included in:
MergePacts
Defined in:
lib/pact_broker/client/merge_pacts.rb

Instance Method Summary collapse

Instance Method Details

#call(pact_hashes) ⇒ Object



12
13
14
# File 'lib/pact_broker/client/merge_pacts.rb', line 12

def call pact_hashes
  pact_hashes.reduce{|p1, p2| merge(p1, p2) }
end

#merge(original, additional) ⇒ Object

Accepts two hashes representing pacts, outputs a merged hash Does not make any guarantees about order of interactions



18
19
20
21
22
23
24
25
# File 'lib/pact_broker/client/merge_pacts.rb', line 18

def merge original, additional
  new_pact = JSON.parse(original.to_json, symbolize_names: true)

  merge_interactions_or_messages(new_pact, original, additional, :interactions)
  merge_interactions_or_messages(new_pact, original, additional, :messages)

  new_pact
end