diff --git a/lib/pact_broker/matrix/service.rb b/lib/pact_broker/matrix/service.rb index 019ed4225..3f7958751 100644 --- a/lib/pact_broker/matrix/service.rb +++ b/lib/pact_broker/matrix/service.rb @@ -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 diff --git a/spec/lib/pact_broker/matrix/service_spec.rb b/spec/lib/pact_broker/matrix/service_spec.rb index 2fee2dc25..3d9c0e4bf 100644 --- a/spec/lib/pact_broker/matrix/service_spec.rb +++ b/spec/lib/pact_broker/matrix/service_spec.rb @@ -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