Skip to content

Commit 6742afa

Browse files
committed
feat: publish beta format of individual interaction results to Pact Broker
1 parent 274f843 commit 6742afa

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

lib/pact/provider/rspec/pact_broker_formatter.rb

+2-16
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,14 @@ module Provider
88
module RSpec
99
class PactBrokerFormatter < ::RSpec::Core::Formatters::BaseFormatter
1010
Pact::RSpec.with_rspec_3 do
11-
::RSpec::Core::Formatters.register self, :message, :dump_summary, :stop, :seed, :close
11+
::RSpec::Core::Formatters.register self, :stop, :close
1212
end
1313

1414
attr_reader :output_hash
1515

1616
def initialize(output)
1717
super
18-
@output_hash = {
19-
:version => ::RSpec::Core::Version::STRING
20-
}
21-
end
22-
23-
def message(notification)
24-
(@output_hash[:messages] ||= []) << notification.message
25-
end
26-
27-
def dump_summary(summary)
18+
@output_hash = {}
2819
end
2920

3021
def stop(notification)
@@ -33,11 +24,6 @@ def stop(notification)
3324
.map { |example| format_example(example) }
3425
end
3526

36-
def seed(notification)
37-
return unless notification.seed_used?
38-
@output_hash[:seed] = notification.seed
39-
end
40-
4127
def close(_notification)
4228
Pact::Provider::VerificationResults::PublishAll.call(Pact.provider_world.pact_sources, output_hash)
4329
end

lib/pact/provider/verification_results/create.rb

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ def test_results_hash_for_pact_uri
5757
summary: {
5858
testCount: examples_for_pact_uri.size,
5959
failureCount: count_failures_for_pact_uri
60+
},
61+
metadata: {
62+
warning: "These test results use a beta format. Do not rely on it, as it will definitely change.",
63+
pactVerificationResultsSpecification: {
64+
version: "1.0.0-beta.1"
65+
}
6066
}
6167
}
6268
end

lib/pact/provider/verification_results/verification_result.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def to_json(options = {})
2424
{
2525
success: success,
2626
providerApplicationVersion: provider_application_version,
27-
#testResults: test_results_hash # not yet
27+
testResults: test_results_hash
2828
}.to_json(options)
2929
end
3030

spec/lib/pact/provider/verification_results/create_spec.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ module VerificationResults
5252
it "creates a VerificationResult with the relevant test results" do
5353
expected_test_results_hash = {
5454
tests: [{ status: "passed" }],
55-
summary: { testCount: 1, failureCount: 0}
55+
summary: { testCount: 1, failureCount: 0},
56+
metadata: {
57+
warning: "These test results use a beta format. Do not rely on it, as it will definitely change.",
58+
pactVerificationResultsSpecification: {
59+
version: "1.0.0-beta.1"
60+
}
61+
}
5662
}
5763
expect(VerificationResult).to receive(:new).with(anything, anything, anything, expected_test_results_hash)
5864
subject

0 commit comments

Comments
 (0)