From 2ac5a946884d7de428b6a2a459db6b7dc83dab40 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Tue, 5 Oct 2021 11:15:23 +1100 Subject: [PATCH] feat(can-i-deploy): support ignoring specific version numbers --- lib/pact_broker/matrix/parse_can_i_deploy_query.rb | 8 +++++--- .../matrix/parse_can_i_deploy_query_spec.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/pact_broker/matrix/parse_can_i_deploy_query.rb b/lib/pact_broker/matrix/parse_can_i_deploy_query.rb index e5fa71f48..069368c06 100644 --- a/lib/pact_broker/matrix/parse_can_i_deploy_query.rb +++ b/lib/pact_broker/matrix/parse_can_i_deploy_query.rb @@ -29,9 +29,11 @@ def self.call params end if params[:ignore].is_a?(Array) - options[:ignore_selectors] = params[:ignore].collect do | pacticipant_name | - if pacticipant_name.is_a?(String) - PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: pacticipant_name) + options[:ignore_selectors] = params[:ignore].collect do | param | + if param.is_a?(String) + PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: param) + elsif param.is_a?(Hash) && param.key?(:pacticipant) + PactBroker::Matrix::UnresolvedSelector.new({ pacticipant_name: param[:pacticipant], pacticipant_version_number: param[:version] }.compact) end end.compact else diff --git a/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb b/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb index c2f83173f..fa83bd767 100644 --- a/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb +++ b/spec/lib/pact_broker/matrix/parse_can_i_deploy_query_spec.rb @@ -38,6 +38,19 @@ module Matrix end end + context "with pacticipant selectors to ignore" do + before do + params[:ignore] = [{ pacticipant: "foo" }, { pacticipant: "bar", version: "2" }] + end + + its([:ignore_selectors]) do + is_expected.to eq [ + PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: "foo"), + PactBroker::Matrix::UnresolvedSelector.new(pacticipant_name: "bar", pacticipant_version_number: "2") + ] + end + end + context "with a tag" do let(:params) do {