From 5ee9dd70d24c3264c75b74fc6e08d409be4a418e Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 9 Nov 2017 12:36:32 +1100 Subject: [PATCH] fix(publish): accept pact file paths using windows separator --- lib/pact_broker/client/cli/broker.rb | 3 ++- .../pact_broker/client/cli/broker_publish_spec.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/pact_broker/client/cli/broker.rb b/lib/pact_broker/client/cli/broker.rb index ee2805c9..46e5d621 100644 --- a/lib/pact_broker/client/cli/broker.rb +++ b/lib/pact_broker/client/cli/broker.rb @@ -104,7 +104,8 @@ def publish_pacts pact_files end def file_list pact_files - Rake::FileList[pact_files].collect do | path | + correctly_separated_pact_files = pact_files.collect{ |path| path.gsub(/\\+/, '/') } + Rake::FileList[correctly_separated_pact_files].collect do | path | if File.directory?(path) Rake::FileList[File.join(path, "*.json")] else diff --git a/spec/lib/pact_broker/client/cli/broker_publish_spec.rb b/spec/lib/pact_broker/client/cli/broker_publish_spec.rb index 01608432..6c54312b 100644 --- a/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +++ b/spec/lib/pact_broker/client/cli/broker_publish_spec.rb @@ -63,6 +63,21 @@ module PactBroker::Client::CLI end end + context "with a windows directory specified" do + let(:file_list) { ['spec\\support\cli_test_pacts'] } + + it "invokes the PublishPacts command with the list of files in the directory" do + expect(PactBroker::Client::PublishPacts).to receive(:call).with( + anything, + ["spec/support/cli_test_pacts/bar.json", "spec/support/cli_test_pacts/foo.json"], + anything, + anything, + anything + ) + invoke_broker + end + end + context "with a tag" do before do subject.options = OpenStruct.new(minimum_valid_options.merge(tag: ['foo']))