Skip to content

Commit

Permalink
feat(pacts for verification): update wording for inclusion notice whe…
Browse files Browse the repository at this point in the history
…n selector has a consumer specified
  • Loading branch information
bethesque committed Sep 25, 2020
1 parent 4486c05 commit 61370d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/pact_broker/pacts/verifiable_pact_messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}'"
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/pact_broker/pacts/verifiable_pact_messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 61370d1

Please sign in to comment.