From 6742afa4ce2bd5ed97272ee531ec2e7a6738b5c9 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 25 Jul 2018 14:45:04 +1000 Subject: [PATCH] feat: publish beta format of individual interaction results to Pact Broker --- .../provider/rspec/pact_broker_formatter.rb | 18 ++---------------- .../provider/verification_results/create.rb | 6 ++++++ .../verification_result.rb | 2 +- .../verification_results/create_spec.rb | 8 +++++++- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/pact/provider/rspec/pact_broker_formatter.rb b/lib/pact/provider/rspec/pact_broker_formatter.rb index fba1a85c..0383062d 100644 --- a/lib/pact/provider/rspec/pact_broker_formatter.rb +++ b/lib/pact/provider/rspec/pact_broker_formatter.rb @@ -8,23 +8,14 @@ module Provider module RSpec class PactBrokerFormatter < ::RSpec::Core::Formatters::BaseFormatter Pact::RSpec.with_rspec_3 do - ::RSpec::Core::Formatters.register self, :message, :dump_summary, :stop, :seed, :close + ::RSpec::Core::Formatters.register self, :stop, :close end attr_reader :output_hash def initialize(output) super - @output_hash = { - :version => ::RSpec::Core::Version::STRING - } - end - - def message(notification) - (@output_hash[:messages] ||= []) << notification.message - end - - def dump_summary(summary) + @output_hash = {} end def stop(notification) @@ -33,11 +24,6 @@ def stop(notification) .map { |example| format_example(example) } end - def seed(notification) - return unless notification.seed_used? - @output_hash[:seed] = notification.seed - end - def close(_notification) Pact::Provider::VerificationResults::PublishAll.call(Pact.provider_world.pact_sources, output_hash) end diff --git a/lib/pact/provider/verification_results/create.rb b/lib/pact/provider/verification_results/create.rb index 55e89c61..2ae5ced2 100644 --- a/lib/pact/provider/verification_results/create.rb +++ b/lib/pact/provider/verification_results/create.rb @@ -57,6 +57,12 @@ def test_results_hash_for_pact_uri summary: { testCount: examples_for_pact_uri.size, failureCount: count_failures_for_pact_uri + }, + metadata: { + warning: "These test results use a beta format. Do not rely on it, as it will definitely change.", + pactVerificationResultsSpecification: { + version: "1.0.0-beta.1" + } } } end diff --git a/lib/pact/provider/verification_results/verification_result.rb b/lib/pact/provider/verification_results/verification_result.rb index 617befca..a39f8ade 100644 --- a/lib/pact/provider/verification_results/verification_result.rb +++ b/lib/pact/provider/verification_results/verification_result.rb @@ -24,7 +24,7 @@ def to_json(options = {}) { success: success, providerApplicationVersion: provider_application_version, - #testResults: test_results_hash # not yet + testResults: test_results_hash }.to_json(options) end diff --git a/spec/lib/pact/provider/verification_results/create_spec.rb b/spec/lib/pact/provider/verification_results/create_spec.rb index c27cd194..55b5e846 100644 --- a/spec/lib/pact/provider/verification_results/create_spec.rb +++ b/spec/lib/pact/provider/verification_results/create_spec.rb @@ -52,7 +52,13 @@ module VerificationResults it "creates a VerificationResult with the relevant test results" do expected_test_results_hash = { tests: [{ status: "passed" }], - summary: { testCount: 1, failureCount: 0} + summary: { testCount: 1, failureCount: 0}, + metadata: { + warning: "These test results use a beta format. Do not rely on it, as it will definitely change.", + pactVerificationResultsSpecification: { + version: "1.0.0-beta.1" + } + } } expect(VerificationResult).to receive(:new).with(anything, anything, anything, expected_test_results_hash) subject