Skip to content

Commit

Permalink
feat: publish beta format of individual interaction results to Pact B…
Browse files Browse the repository at this point in the history
…roker
  • Loading branch information
bethesque committed Jul 25, 2018
1 parent 274f843 commit 6742afa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
18 changes: 2 additions & 16 deletions lib/pact/provider/rspec/pact_broker_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions lib/pact/provider/verification_results/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion spec/lib/pact/provider/verification_results/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6742afa

Please sign in to comment.