-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pacts for verification): include a short description of the pact…
…'s selectors in the response
- Loading branch information
Showing
6 changed files
with
168 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'pact_broker/pacts/verifiable_pact_messages' | ||
|
||
module PactBroker | ||
module Pacts | ||
class BuildVerifiablePactNotices | ||
|
||
def self.call(verifiable_pact, pact_url, options) | ||
messages = VerifiablePactMessages.new(verifiable_pact, pact_url) | ||
|
||
notices = [{ | ||
when: 'before_verification', | ||
text: messages.inclusion_reason | ||
}] | ||
|
||
if options[:include_pending_status] | ||
append_notice(notices, 'before_verification', messages.pending_reason) | ||
append_notice(notices, 'after_verification:success_true_published_false', messages.verification_success_true_published_false) | ||
append_notice(notices, 'after_verification:success_false_published_false', messages.verification_success_false_published_false) | ||
append_notice(notices, 'after_verification:success_true_published_true', messages.verification_success_true_published_true) | ||
append_notice(notices, 'after_verification:success_false_published_true', messages.verification_success_false_published_true) | ||
end | ||
notices | ||
end | ||
|
||
def self.append_notice notices, the_when, text | ||
if text | ||
notices << { | ||
when: the_when, | ||
text: text | ||
} | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
spec/lib/pact_broker/pacts/build_verifiable_pact_notices_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
require 'pact_broker/pacts/build_verifiable_pact_notices' | ||
|
||
module PactBroker | ||
module Pacts | ||
describe BuildVerifiablePactNotices do | ||
before do | ||
allow(VerifiablePactMessages).to receive(:new).and_return(verifiable_pact_messages) | ||
end | ||
|
||
let(:verifiable_pact_messages) do | ||
instance_double(VerifiablePactMessages, | ||
inclusion_reason: 'the inclusion reason', | ||
pending_reason: 'pending reason', | ||
verification_success_true_published_false: 'verification_success_true_published_false', | ||
verification_success_false_published_false: 'verification_success_false_published_false', | ||
verification_success_true_published_true: 'verification_success_true_published_true', | ||
verification_success_false_published_true: 'verification_success_false_published_true' | ||
) | ||
end | ||
|
||
let(:options) { {} } | ||
let(:pact_url) { 'http://pact' } | ||
let(:verifiable_pact) { instance_double('PactBroker::Pacts::VerifiablePact') } | ||
|
||
subject { BuildVerifiablePactNotices.call(verifiable_pact, pact_url, options) } | ||
|
||
|
||
context "when include_pending_status is true" do | ||
let(:expected_notices) do | ||
[ | ||
{ | ||
:when => "before_verification", | ||
:text => "the inclusion reason" | ||
},{ | ||
:when => "before_verification", | ||
:text => 'pending reason' | ||
},{ | ||
:when => "after_verification:success_true_published_false", | ||
:text => "verification_success_true_published_false" | ||
},{ | ||
:when => "after_verification:success_false_published_false", | ||
:text => "verification_success_false_published_false" | ||
},{ | ||
:when => "after_verification:success_true_published_true", | ||
:text => "verification_success_true_published_true" | ||
},{ | ||
:when => "after_verification:success_false_published_true", | ||
:text => "verification_success_false_published_true" | ||
} | ||
] | ||
end | ||
|
||
let(:options) { { include_pending_status: true } } | ||
|
||
it "it returns a list of notices with information about the pending status" do | ||
expect(subject).to eq expected_notices | ||
end | ||
end | ||
|
||
context "when include_pending_status is not true" do | ||
let(:expected_notices) do | ||
[ | ||
{ | ||
:when => "before_verification", | ||
:text => "the inclusion reason" | ||
} | ||
] | ||
end | ||
|
||
it "it returns a list of notices without information about the pending status" do | ||
expect(subject).to eq expected_notices | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters