Skip to content

Commit 9238e4c

Browse files
committed
feat: allow verbose flag to be set when publishing verifications
1 parent d6ce29f commit 9238e4c

File tree

8 files changed

+16
-12
lines changed

8 files changed

+16
-12
lines changed

lib/pact/cli.rb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def self.exit_on_failure? # Thor 1.0 deprecation guard
1616
method_option :pact_broker_password, aliases: "-w", desc: "Pact broker password"
1717
method_option :pact_broker_token, aliases: "-k", desc: "Pact broker token"
1818
method_option :backtrace, aliases: "-b", desc: "Show full backtrace", :default => false, :type => :boolean
19+
method_option :verbose, aliases: "-v", desc: "Show verbose HTTP logging", :default => false, :type => :boolean
1920
method_option :interactions_replay_order, aliases: "-o",
2021
desc: "Interactions replay order: randomised or recorded (default)",
2122
default: Pact.configuration.interactions_replay_order

lib/pact/cli/run_pact_verification.rb

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def run_with_configured_pacts_from_pact_helper
7979
def pact_spec_options
8080
{
8181
full_backtrace: options[:backtrace],
82+
verbose: options[:verbose] || ENV['VERBOSE'] == 'true',
8283
criteria: SpecCriteria.call(options),
8384
format: options[:format],
8485
out: options[:out],

lib/pact/provider/pact_spec_runner.rb

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def configure_rspec
7575
end
7676

7777
# For the Pact::Provider::RSpec::PactBrokerFormatter
78+
Pact.provider_world.verbose = options[:verbose]
7879
Pact.provider_world.pact_sources = pact_sources
7980
jsons = pact_jsons
8081
executing_with_ruby = executing_with_ruby?

lib/pact/provider/rspec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def honour_pactfile pact_source, pact_json, options
3636
pact_source: pact_source,
3737
consumer_contract: consumer_contract,
3838
criteria: options[:criteria]
39-
)
39+
)
4040
end
4141
end
4242

lib/pact/provider/rspec/pact_broker_formatter.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def stop(notification)
2525
end
2626

2727
def close(_notification)
28-
Pact::Provider::VerificationResults::PublishAll.call(Pact.provider_world.pact_sources, output_hash)
28+
Pact::Provider::VerificationResults::PublishAll.call(Pact.provider_world.pact_sources, output_hash, { verbose: Pact.provider_world.verbose })
2929
end
3030

3131
private

lib/pact/provider/verification_results/publish.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ class Publish
1717
PROVIDER_RELATION = 'pb:provider'.freeze
1818
VERSION_TAG_RELATION = 'pb:version-tag'.freeze
1919

20-
def self.call pact_source, verification_result
21-
new(pact_source, verification_result).call
20+
def self.call pact_source, verification_result, options = {}
21+
new(pact_source, verification_result, options).call
2222
end
2323

24-
def initialize pact_source, verification_result
24+
def initialize pact_source, verification_result, options = {}
2525
@pact_source = pact_source
2626
@verification_result = verification_result
2727
http_client_options = pact_source.uri.options.reject{ |k, v| ![:username, :password, :token].include?(k) }
28-
@http_client = Pact::Hal::HttpClient.new(http_client_options)
28+
@http_client = Pact::Hal::HttpClient.new(http_client_options.merge(verbose: options[:verbose]))
2929
@pact_entity = Pact::Hal::Entity.new(pact_source.uri, pact_source.pact_hash, http_client)
3030
end
3131

lib/pact/provider/verification_results/publish_all.rb

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ module Provider
66
module VerificationResults
77
class PublishAll
88

9-
def self.call pact_sources, test_results_hash
10-
new(pact_sources, test_results_hash).call
9+
def self.call pact_sources, test_results_hash, options = {}
10+
new(pact_sources, test_results_hash, options).call
1111
end
1212

13-
def initialize pact_sources, test_results_hash
13+
def initialize pact_sources, test_results_hash, options = {}
1414
@pact_sources = pact_sources
1515
@test_results_hash = test_results_hash
16+
@options = options
1617
end
1718

1819
def call
1920
verification_results.collect do | (pact_source, verification_result) |
2021
published = false
2122
begin
22-
published = Publish.call(pact_source, verification_result)
23+
published = Publish.call(pact_source, verification_result, { verbose: options[:verbose] })
2324
ensure
2425
print_after_verification_notices(pact_source, verification_result, published)
2526
end
@@ -42,7 +43,7 @@ def print_after_verification_notices(pact_source, verification_result, published
4243
end
4344
end
4445

45-
attr_reader :pact_sources, :test_results_hash
46+
attr_reader :pact_sources, :test_results_hash, :options
4647
end
4748
end
4849
end

lib/pact/provider/world.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def self.clear_provider_world
1414
module Provider
1515
class World
1616

17-
attr_accessor :pact_sources, :failed_examples
17+
attr_accessor :pact_sources, :failed_examples, :verbose
1818

1919
def provider_states
2020
@provider_states_proxy ||= Pact::Provider::State::ProviderStateProxy.new

0 commit comments

Comments
 (0)