From bdc2711c1e5a1064f6ac705b40a01eb8550ca62a Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 22 Jan 2020 12:43:51 +1100 Subject: [PATCH] feat: expose full notice object in JSON output --- lib/pact/pact_broker/fetch_pact_uris_for_verification.rb | 6 +++++- lib/pact/provider/rspec.rb | 2 +- .../pact_ruby_fetch_pacts_for_verification_test.rb | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb b/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb index f7cb8f1d..125993ec 100644 --- a/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb +++ b/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb @@ -73,7 +73,11 @@ def query end def extract_notices(pact) - (pact["verificationProperties"]["notices"] || []).collect{ |notice| notice["text"] }.compact + (pact["verificationProperties"]["notices"] || []).collect{ |notice| symbolize_keys(notice) }.compact + end + + def symbolize_keys(hash) + hash.each_with_object({}){ |(k,v), h| h[k.to_sym] = v } end def log_message diff --git a/lib/pact/provider/rspec.rb b/lib/pact/provider/rspec.rb index cac9380b..62fc30a7 100644 --- a/lib/pact/provider/rspec.rb +++ b/lib/pact/provider/rspec.rb @@ -24,7 +24,7 @@ module ClassMethods def honour_pactfile pact_uri, pact_json, options Pact.configuration.output_stream.puts "INFO: Reading pact at #{pact_uri}" (pact_uri.metadata[:notices] || EMPTY_ARRAY).each do | notice | - Pact.configuration.output_stream.puts("DEBUG: #{notice}") + Pact.configuration.output_stream.puts("DEBUG: #{notice[:text]}") end Pact.configuration.output_stream.puts "DEBUG: Filtering interactions by: #{options[:criteria]}" if options[:criteria] && options[:criteria].any? consumer_contract = Pact::ConsumerContract.from_json(pact_json) diff --git a/spec/service_providers/pact_ruby_fetch_pacts_for_verification_test.rb b/spec/service_providers/pact_ruby_fetch_pacts_for_verification_test.rb index e8b36f07..4c762acb 100644 --- a/spec/service_providers/pact_ruby_fetch_pacts_for_verification_test.rb +++ b/spec/service_providers/pact_ruby_fetch_pacts_for_verification_test.rb @@ -92,7 +92,9 @@ let(:expected_metadata) do { pending: true, - notices: ["some text"] + notices: [ + text: "some text" + ] } end