summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-03-30 15:04:36 -0400
committerHo-Sheng Hsiao <hosh@opscode.com>2012-05-10 14:43:54 -0400
commitae4e4ab49b8275dc322b930bebe44c3cf24341f0 (patch)
treee01ff93b313a97d3d2b761cb792fbfcd0d9906c6 /spec
parent110a028f1b1782d7ce6f6d9b871059263ca05b69 (diff)
downloadmixlib-shellout-ae4e4ab49b8275dc322b930bebe44c3cf24341f0.tar.gz
[CHEF-2994][WINDOWS] Fixed multiple quotes for non batch files
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout/shellout_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/mixlib/shellout/shellout_spec.rb b/spec/mixlib/shellout/shellout_spec.rb
index b532827..00701a6 100644
--- a/spec/mixlib/shellout/shellout_spec.rb
+++ b/spec/mixlib/shellout/shellout_spec.rb
@@ -412,6 +412,7 @@ describe Mixlib::ShellOut do
it 'should execute' do
should eql(argument)
end
+
context 'with multiple quotes in the command and args' do
context 'when using a batch file' do
let(:argument) { "\"Random #{rand(10000)}\"" }
@@ -420,6 +421,23 @@ describe Mixlib::ShellOut do
should eql(argument)
end
end
+
+ context 'when not using a batch file' do
+ let(:watch) { lambda { |a| ap a } }
+ let(:cmd) { "#{executable_file_name} #{script_name}" }
+
+ let(:executable_file_name) { "\"#{dir}/Ruby Parser.exe\"".tap(&make_executable!) }
+ let(:make_executable!) { lambda { |filename| Mixlib::ShellOut.new("copy \"#{full_path_to_ruby}\" #{filename}").run_command } }
+ let(:script_content) { "print \"#{expected_output}\"" }
+ let(:expected_output) { "Random #{rand(10000)}" }
+
+ let(:full_path_to_ruby) { ENV['PATH'].split(';').map(&try_ruby).reject(&:nil?).first }
+ let(:try_ruby) { lambda { |path| "#{path}\\ruby.exe" if File.executable? "#{path}\\ruby.exe" } }
+
+ it 'should execute' do
+ should eql(expected_output)
+ end
+ end
end
end
end