forked from pact-foundation/pact-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pact metadata to json formatter
- Loading branch information
Showing
14 changed files
with
157 additions
and
23 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,34 @@ | ||
module Pact | ||
module PactBroker | ||
class Notices < Array | ||
def before_verification_notices | ||
select { | notice | notice[:when].nil? || notice[:when].start_with?('before_verification') } | ||
end | ||
|
||
def before_verification_notices_text | ||
before_verification_notices.collect{ | notice | notice[:text] } | ||
end | ||
|
||
def after_verification_notices(success, published) | ||
select { | notice | notice[:when] == "after_verification:success_#{success}_published_#{published}" || notice[:when] == "after_verification" } | ||
.collect do | notice | | ||
notice.merge(:when => simplify_notice_when(notice[:when])) | ||
end | ||
end | ||
|
||
def after_verification_notices_text(success, published) | ||
after_verification_notices(success, published).collect{ | notice | notice[:text] } | ||
end | ||
|
||
def all_notices(success, published) | ||
before_verification_notices + after_verification_notices(success, published) | ||
end | ||
|
||
private | ||
|
||
def simplify_notice_when(when_key) | ||
when_key.split(":").first | ||
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
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
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
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
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,58 @@ | ||
require 'pact/pact_broker/notices' | ||
|
||
module Pact | ||
module PactBroker | ||
describe Notices do | ||
|
||
let(:notice_hashes) do | ||
[ | ||
{ text: "foo", when: "before_verification" } | ||
] | ||
end | ||
|
||
subject(:notices) { Notices.new(notice_hashes) } | ||
|
||
it "behaves like an array" do | ||
expect(subject.size).to eq notice_hashes.size | ||
end | ||
|
||
describe "before_verification_notices" do | ||
let(:notice_hashes) do | ||
[ | ||
{ text: "foo", when: "before_verification" }, | ||
{ text: "bar", when: "blah" }, | ||
] | ||
end | ||
|
||
its(:before_verification_notices_text) { is_expected.to eq [ "foo" ] } | ||
end | ||
|
||
describe "after_verification_notices_text" do | ||
let(:notice_hashes) do | ||
[ | ||
{ text: "foo", when: "after_verification:success_false_published_true" }, | ||
{ text: "bar", when: "blah" }, | ||
] | ||
end | ||
|
||
subject { notices.after_verification_notices_text(false, true) } | ||
|
||
it { is_expected.to eq [ "foo" ] } | ||
end | ||
|
||
describe "after_verification_notices" do | ||
let(:notice_hashes) do | ||
[ | ||
{ text: "meep", when: "after_verification" }, | ||
{ text: "foo", when: "after_verification:success_false_published_true" }, | ||
{ text: "bar", when: "blah" }, | ||
] | ||
end | ||
|
||
subject { notices.after_verification_notices(false, true) } | ||
|
||
it { is_expected.to eq [{ text: "meep", when: "after_verification" }, { text: "foo", when: "after_verification" }] } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require 'rspec' | ||
require 'rspec/its' | ||
require 'fakefs/spec_helpers' | ||
require 'pact' | ||
require 'webmock/rspec' | ||
|