Skip to content

Commit

Permalink
feat(matrix): show validation message for correct version selector
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 10, 2017
1 parent 7f91710 commit 136d8fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/pact_broker/matrix/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def validate_selectors selectors
selected_versions = version_service.find_versions_by_selector(selectors)
if selected_versions.any?(&:nil?)
selected_versions.each_with_index do | selected_version, i |
error_messages << "No pact or verification found for #{selectors[i]}"
error_messages << "No pact or verification found for #{selectors[i]}" if selected_version.nil?
end
end
end
Expand Down
8 changes: 6 additions & 2 deletions spec/lib/pact_broker/matrix/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ module Matrix
context "when one or more of the selectors does not match any known version" do
before do
td.create_pacticipant("Foo")
.create_version("1")
.create_pacticipant("Bar")
.create_version("2")

end

let(:selectors) { ["Foo/version/1"] }
let(:selectors) { ["Foo/version/1", "Bar/version/1"] }

it "returns error messages" do
expect(subject.first).to eq "No pact or verification found for Foo/version/1"
expect(subject).to eq ["No pact or verification found for Bar/version/1"]
end
end

Expand Down

0 comments on commit 136d8fb

Please sign in to comment.