From 7dc0e4340ed6b2d4100d5f9b135c7c7fd697230d Mon Sep 17 00:00:00 2001 From: Ben Dean Date: Fri, 11 Jul 2014 17:08:07 -0400 Subject: [PATCH 1/2] adding failing tests for fixnum args in an array. The args need to be strings so that an error won't happen with `text.gsub` in https://github.com/mitchellh/vagrant/blob/bb052366f7f9616666299a97edcceadae007394a/plugins/provisioners/shell/provisioner.rb#L122 See my comments on mitchellh/vagrant#2982 as to why it needs to test for this. --- .../plugins/provisioners/shell/config_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/unit/plugins/provisioners/shell/config_test.rb b/test/unit/plugins/provisioners/shell/config_test.rb index 9827e66e8..946b4c2a8 100644 --- a/test/unit/plugins/provisioners/shell/config_test.rb +++ b/test/unit/plugins/provisioners/shell/config_test.rb @@ -86,4 +86,22 @@ describe "VagrantPlugins::Shell::Config" do ]) end end + + describe 'finalize!' do + it 'changes fixnum args into strings' do + subject.path = file_that_exists + subject.args = 1 + subject.finalize! + + expect(subject.args).to eq '1' + end + + it 'changes fixnum args in arrays into strings' do + subject.path = file_that_exists + subject.args = ["string", 1, 2] + subject.finalize! + + expect(subject.args).to eq ["string", '1', '2'] + end + end end From dbb92ae412dcd270e561cfa580d5f15520290204 Mon Sep 17 00:00:00 2001 From: Ben Dean Date: Fri, 11 Jul 2014 17:09:31 -0400 Subject: [PATCH 2/2] change the shell provision config to make all the args strings specifically arrays could contain `Fixnum` args and those wouldn't get turned into strings. --- plugins/provisioners/shell/config.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/provisioners/shell/config.rb b/plugins/provisioners/shell/config.rb index 211090dcc..fbb7c812e 100644 --- a/plugins/provisioners/shell/config.rb +++ b/plugins/provisioners/shell/config.rb @@ -30,8 +30,8 @@ module VagrantPlugins @binary = false if @binary == UNSET_VALUE @keep_color = false if @keep_color == UNSET_VALUE - if @args && !@args.is_a?(Array) && args_valid? - @args = @args.to_s + if @args && args_valid? + @args = @args.is_a?(Array) ? @args.map { |a| a.to_s } : @args.to_s end end