diff --git a/lib/pact_broker/pacts/verifiable_pact_messages.rb b/lib/pact_broker/pacts/verifiable_pact_messages.rb index 246f89571..d1c0a3960 100644 --- a/lib/pact_broker/pacts/verifiable_pact_messages.rb +++ b/lib/pact_broker/pacts/verifiable_pact_messages.rb @@ -131,12 +131,14 @@ def selector_descriptions def selector_description selector if selector.overall_latest? - "latest pact between a consumer and #{provider_name}" + consumer_label = selector.consumer ? selector.consumer : 'a consumer' + "latest pact between #{consumer_label} and #{provider_name}" elsif selector.latest_for_tag? + version_label = selector.consumer ? "version of #{selector.consumer}" : "consumer version" if selector.fallback_tag? - "latest pact for a consumer version tagged '#{selector.fallback_tag}' (fallback tag used as no pact was found with tag '#{selector.tag}')" + "latest pact for a #{version_label} tagged '#{selector.fallback_tag}' (fallback tag used as no pact was found with tag '#{selector.tag}')" else - "latest pact for a consumer version tagged '#{selector.tag}'" + "latest pact for a #{version_label} tagged '#{selector.tag}'" end elsif selector.all_for_tag_and_consumer? "pacts for all #{selector.consumer} versions tagged '#{selector.tag}'" diff --git a/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb b/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb index 26e056592..2229381f4 100644 --- a/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb +++ b/spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb @@ -73,6 +73,18 @@ module Pacts its(:inclusion_reason) { is_expected.to include "The pact at http://pact is being verified because it matches the following configured selection criterion: pacts for all Foo versions tagged 'prod'"} end + + context "when the pact is the latest versions for a tag and consumer" do + let(:selectors) { Selectors.new(Selector.latest_for_tag_and_consumer('prod', 'Foo')) } + + its(:inclusion_reason) { is_expected.to include "The pact at http://pact is being verified because it matches the following configured selection criterion: latest pact for a version of Foo tagged 'prod'"} + end + + context "when the pact is the latest version for and consumer" do + let(:selectors) { Selectors.new(Selector.latest_for_consumer('Foo')) } + + its(:inclusion_reason) { is_expected.to include "The pact at http://pact is being verified because it matches the following configured selection criterion: latest pact between Foo and Bar"} + end end describe "#pending_reason" do