-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(can-i-deploy): display links to verification results in the outp…
…ut of can-i-deploy when using text format
- Loading branch information
Showing
9 changed files
with
192 additions
and
38 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
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,29 +1,54 @@ | ||
require 'pact_broker/client/matrix/resource' | ||
require 'pact_broker/client/matrix/text_formatter' | ||
|
||
module PactBroker | ||
module Client | ||
describe Matrix::TextFormatter do | ||
let(:matrix_lines) { JSON.parse(File.read('spec/support/matrix.json'), symbolize_names: true)[:matrix] } | ||
let(:matrix) { PactBroker::Client::Matrix::Resource.new(JSON.parse(File.read('spec/support/matrix.json'), symbolize_names: true)) } | ||
let(:expected_matrix_lines) { File.read('spec/support/matrix.txt') } | ||
|
||
# SublimeText removes whitespace from the end of files when you save them, | ||
# so removing trailing whitespace before comparing | ||
subject { Matrix::TextFormatter.call(matrix: matrix_lines).split("\n").collect(&:strip).join("\n") } | ||
def strip_trailing_whitespace(text) | ||
text.split("\n").collect(&:strip).join("\n") | ||
end | ||
|
||
subject { strip_trailing_whitespace(Matrix::TextFormatter.call(matrix)) } | ||
|
||
context "with valid data" do | ||
it "it has the right text" do | ||
expect(subject).to eq expected_matrix_lines | ||
expect(subject).to start_with expected_matrix_lines | ||
end | ||
end | ||
|
||
context "with invalid data" do | ||
let(:expected_matrix_lines) { File.read('spec/support/matrix_error.txt') } | ||
let(:matrix_lines) { [{}] } | ||
let(:matrix) { PactBroker::Client::Matrix::Resource.new(matrix: [{}]) } | ||
|
||
it "doesn't blow up" do | ||
expect(subject).to eq expected_matrix_lines | ||
end | ||
end | ||
|
||
context "when some rows have a verification result URL and some don't" do | ||
let(:matrix_lines) do | ||
line_creator = -> { JSON.parse(File.read('spec/support/matrix.json'), symbolize_names: true)[:matrix].first } | ||
line_1 = line_creator.call | ||
line_2 = line_creator.call | ||
line_3 = line_creator.call | ||
line_2[:verificationResult] = nil | ||
line_3[:verificationResult][:success] = false | ||
[line_1, line_2, line_3] | ||
end | ||
|
||
let(:matrix) { PactBroker::Client::Matrix::Resource.new(matrix: matrix_lines) } | ||
|
||
let(:expected_matrix_lines) { File.read('spec/support/matrix_with_results.txt') } | ||
|
||
it "only provides a result number for the lines that have a result URL" do | ||
expect(subject).to eq expected_matrix_lines | ||
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
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,3 +1,3 @@ | ||
CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | ||
---------|-----------|----------|-----------|--------- | ||
Foo | 4 | Bar | 5 | true | ||
CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT# | ||
---------|-----------|----------|-----------|----------|-------- | ||
Foo | 4 | Bar | 5 | true | 1 |
Oops, something went wrong.