summaryrefslogtreecommitdiff
path: root/spec/mixlib/shellout
diff options
context:
space:
mode:
authorHo-Sheng Hsiao <hosheng.hsiao@gmail.com>2012-04-02 18:45:02 -0400
committerHo-Sheng Hsiao <hosh@opscode.com>2012-05-10 14:51:43 -0400
commitec7dfe16926ebb7ecfefda365e5706954b761c3a (patch)
treecf062be53e0a451870a8c27accbb175a95c8afc7 /spec/mixlib/shellout
parent146de90bee9a19f97a2b13595d39cbd99cb7eb77 (diff)
downloadmixlib-shellout-ec7dfe16926ebb7ecfefda365e5706954b761c3a.tar.gz
[CHEF-2994][WINDOWS] Expanded Utils.should_run_under_cmd?() to work like Ruby system()
Diffstat (limited to 'spec/mixlib/shellout')
-rw-r--r--spec/mixlib/shellout/windows_spec.rb60
1 files changed, 44 insertions, 16 deletions
diff --git a/spec/mixlib/shellout/windows_spec.rb b/spec/mixlib/shellout/windows_spec.rb
index 4e6b83f..f35c398 100644
--- a/spec/mixlib/shellout/windows_spec.rb
+++ b/spec/mixlib/shellout/windows_spec.rb
@@ -13,22 +13,50 @@ describe 'Mixlib::ShellOut::Windows', :windows_only => true do
end
end
- with_command(%q{ruby -e 'prints "foobar"'}) { should_not be_true }
-
- # https://github.com/opscode/mixlib-shellout/pull/2#issuecomment-4825574
- with_command(%q{"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe" /i "C:\Program Files (x86)\NUnit 2.6\bin\framework\nunit.framework.dll"}) { should_not be_true }
-
- with_command(%q{ruby -e 'exit 1' | ruby -e 'exit 0'}) { should be_true }
- with_command(%q{ruby -e 'exit 1' > out.txt}) { should be_true }
- with_command(%q{ruby -e 'exit 1' > out.txt 2>&1}) { should be_true }
- with_command(%q{ruby -e 'exit 1' < in.txt}) { should be_true }
- with_command(%q{ruby -e 'exit 1' || ruby -e 'exit 0'}) { should be_true }
- with_command(%q{ruby -e 'exit 1' && ruby -e 'exit 0'}) { should be_true }
- with_command(%q{@echo TRUE}) { should be_true }
- with_command(%q{echo %PATH%}) { should be_true }
-
- # TODO: It would be awesome if it can detect quoted special characters
- with_command(%q{echo "ruby -e 'exit 1' || ruby -e 'exit 0'"}) { should be_true }
+ context 'when unquoted' do
+ with_command(%q{ruby -e 'prints "foobar"'}) { should_not be_true }
+
+ # https://github.com/opscode/mixlib-shellout/pull/2#issuecomment-4825574
+ with_command(%q{"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe" /i "C:\Program Files (x86)\NUnit 2.6\bin\framework\nunit.framework.dll"}) { should_not be_true }
+
+ with_command(%q{ruby -e 'exit 1' | ruby -e 'exit 0'}) { should be_true }
+ with_command(%q{ruby -e 'exit 1' > out.txt}) { should be_true }
+ with_command(%q{ruby -e 'exit 1' > out.txt 2>&1}) { should be_true }
+ with_command(%q{ruby -e 'exit 1' < in.txt}) { should be_true }
+ with_command(%q{ruby -e 'exit 1' || ruby -e 'exit 0'}) { should be_true }
+ with_command(%q{ruby -e 'exit 1' && ruby -e 'exit 0'}) { should be_true }
+ with_command(%q{@echo TRUE}) { should be_true }
+
+ with_command(%q{echo %PATH%}) { should be_true }
+ with_command(%q{run.exe %A}) { should be_false }
+ with_command(%q{run.exe B%}) { should be_false }
+ with_command(%q{run.exe %A B%}) { should be_false }
+ with_command(%q{run.exe %A B% %PATH%}) { should be_true }
+ with_command(%q{run.exe %A B% %_PATH%}) { should be_true }
+ with_command(%q{run.exe %A B% %PATH_EXT%}) { should be_true }
+ with_command(%q{run.exe %A B% %1%}) { should be_false }
+ with_command(%q{run.exe %A B% %PATH1%}) { should be_true }
+ with_command(%q{run.exe %A B% %_PATH1%}) { should be_true }
+ end
+
+ context 'when quoted' do
+ with_command(%q{run.exe "ruby -e 'exit 1' || ruby -e 'exit 0'"}) { should be_false }
+ with_command(%q{run.exe "ruby -e 'exit 1' > out.txt"}) { should be_false }
+ with_command(%q{run.exe "ruby -e 'exit 1' > out.txt 2>&1"}) { should be_false }
+ with_command(%q{run.exe "ruby -e 'exit 1' < in.txt"}) { should be_false }
+ with_command(%q{run.exe "ruby -e 'exit 1' || ruby -e 'exit 0'"}) { should be_false }
+ with_command(%q{run.exe "ruby -e 'exit 1' && ruby -e 'exit 0'"}) { should be_false }
+ with_command(%q{run.exe "%PATH%"}) { should be_true }
+ with_command(%q{run.exe "%A"}) { should be_false }
+ with_command(%q{run.exe "B%"}) { should be_false }
+ with_command(%q{run.exe "%A B%"}) { should be_false }
+ with_command(%q{run.exe "%A B% %PATH%"}) { should be_true }
+ with_command(%q{run.exe "%A B% %_PATH%"}) { should be_true }
+ with_command(%q{run.exe "%A B% %PATH_EXT%"}) { should be_true }
+ with_command(%q{run.exe "%A B% %1%"}) { should be_false }
+ with_command(%q{run.exe "%A B% %PATH1%"}) { should be_true }
+ with_command(%q{run.exe "%A B% %_PATH1%"}) { should be_true }
+ end
end
end