summaryrefslogtreecommitdiff
path: root/spec/mixlib/shellout/windows_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mixlib/shellout/windows_spec.rb')
-rw-r--r--spec/mixlib/shellout/windows_spec.rb210
1 files changed, 105 insertions, 105 deletions
diff --git a/spec/mixlib/shellout/windows_spec.rb b/spec/mixlib/shellout/windows_spec.rb
index 4d9359f..d3fb26b 100644
--- a/spec/mixlib/shellout/windows_spec.rb
+++ b/spec/mixlib/shellout/windows_spec.rb
@@ -14,97 +14,97 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
end
context 'when unquoted' do
- with_command(%q{ruby -e 'prints "foobar"'}) { should_not be_true }
+ with_command(%q{ruby -e 'prints "foobar"'}) { is_expected.not_to be_truthy }
# 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 }
+ 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"}) { is_expected.not_to be_truthy }
+
+ with_command(%q{ruby -e 'exit 1' | ruby -e 'exit 0'}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e 'exit 1' > out.txt}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e 'exit 1' > out.txt 2>&1}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e 'exit 1' < in.txt}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e 'exit 1' || ruby -e 'exit 0'}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e 'exit 1' && ruby -e 'exit 0'}) { is_expected.to be_truthy }
+ with_command(%q{@echo TRUE}) { is_expected.to be_truthy }
+
+ with_command(%q{echo %PATH%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe %A}) { is_expected.to be_falsey }
+ with_command(%q{run.exe B%}) { is_expected.to be_falsey }
+ with_command(%q{run.exe %A B%}) { is_expected.to be_falsey }
+ with_command(%q{run.exe %A B% %PATH%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe %A B% %_PATH%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe %A B% %PATH_EXT%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe %A B% %1%}) { is_expected.to be_falsey }
+ with_command(%q{run.exe %A B% %PATH1%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe %A B% %_PATH1%}) { is_expected.to be_truthy }
context 'when outside quotes' do
- 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{ruby -e "exit 1" | ruby -e "exit 0"}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e "exit 1" > out.txt}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e "exit 1" > out.txt 2>&1}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e "exit 1" < in.txt}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e "exit 1" || ruby -e "exit 0"}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e "exit 1" && ruby -e "exit 0"}) { is_expected.to be_truthy }
+ with_command(%q{@echo "TRUE"}) { is_expected.to be_truthy }
context 'with unclosed quote' do
- 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 }
+ with_command(%q{ruby -e "exit 1" | ruby -e "exit 0}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e "exit 1" > "out.txt}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e "exit 1" > "out.txt 2>&1}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e "exit 1" < "in.txt}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e "exit 1" || "ruby -e "exit 0"}) { is_expected.to be_truthy }
+ with_command(%q{ruby -e "exit 1" && "ruby -e "exit 0"}) { is_expected.to be_truthy }
+ with_command(%q{@echo "TRUE}) { is_expected.to be_truthy }
+
+ with_command(%q{echo "%PATH%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "B%}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%A B%}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%A B% %PATH%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %_PATH%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %PATH_EXT%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %1%}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%A B% %PATH1%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %_PATH1%}) { is_expected.to be_truthy }
end
end
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 }
+ with_command(%q{run.exe "ruby -e 'exit 1' || ruby -e 'exit 0'"}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "ruby -e 'exit 1' > out.txt"}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "ruby -e 'exit 1' > out.txt 2>&1"}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "ruby -e 'exit 1' < in.txt"}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "ruby -e 'exit 1' || ruby -e 'exit 0'"}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "ruby -e 'exit 1' && ruby -e 'exit 0'"}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%PATH%"}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A"}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "B%"}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%A B%"}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%A B% %PATH%"}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %_PATH%"}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %PATH_EXT%"}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %1%"}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%A B% %PATH1%"}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %_PATH1%"}) { is_expected.to be_truthy }
context 'with unclosed quote' 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 }
+ with_command(%q{run.exe "ruby -e 'exit 1' || ruby -e 'exit 0'}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "ruby -e 'exit 1' > out.txt}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "ruby -e 'exit 1' > out.txt 2>&1}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "ruby -e 'exit 1' < in.txt}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "ruby -e 'exit 1' || ruby -e 'exit 0'}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "ruby -e 'exit 1' && ruby -e 'exit 0'}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%PATH%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "B%}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%A B%}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%A B% %PATH%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %_PATH%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %PATH_EXT%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %1%}) { is_expected.to be_falsey }
+ with_command(%q{run.exe "%A B% %PATH1%}) { is_expected.to be_truthy }
+ with_command(%q{run.exe "%A B% %_PATH1%}) { is_expected.to be_truthy }
end
end
end
@@ -124,20 +124,20 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
end
end
- with_candidate('valid .bat file', :candidate => 'autoexec.bat') { should be_true }
- with_candidate('valid .cmd file', :candidate => 'autoexec.cmd') { should be_true }
- with_candidate('valid quoted .bat file', :candidate => '"C:\Program Files\autoexec.bat"') { should be_true }
- with_candidate('valid quoted .cmd file', :candidate => '"C:\Program Files\autoexec.cmd"') { should be_true }
+ with_candidate('valid .bat file', :candidate => 'autoexec.bat') { is_expected.to be_truthy }
+ with_candidate('valid .cmd file', :candidate => 'autoexec.cmd') { is_expected.to be_truthy }
+ with_candidate('valid quoted .bat file', :candidate => '"C:\Program Files\autoexec.bat"') { is_expected.to be_truthy }
+ with_candidate('valid quoted .cmd file', :candidate => '"C:\Program Files\autoexec.cmd"') { is_expected.to be_truthy }
- with_candidate('invalid .bat file', :candidate => 'autoexecbat') { should_not be_true }
- with_candidate('invalid .cmd file', :candidate => 'autoexeccmd') { should_not be_true }
- with_candidate('bat in filename', :candidate => 'abattoir.exe') { should_not be_true }
- with_candidate('cmd in filename', :candidate => 'parse_cmd.exe') { should_not be_true }
+ with_candidate('invalid .bat file', :candidate => 'autoexecbat') { is_expected.not_to be_truthy }
+ with_candidate('invalid .cmd file', :candidate => 'autoexeccmd') { is_expected.not_to be_truthy }
+ with_candidate('bat in filename', :candidate => 'abattoir.exe') { is_expected.not_to be_truthy }
+ with_candidate('cmd in filename', :candidate => 'parse_cmd.exe') { is_expected.not_to be_truthy }
- with_candidate('invalid quoted .bat file', :candidate => '"C:\Program Files\autoexecbat"') { should_not be_true }
- with_candidate('invalid quoted .cmd file', :candidate => '"C:\Program Files\autoexeccmd"') { should_not be_true }
- with_candidate('quoted bat in filename', :candidate => '"C:\Program Files\abattoir.exe"') { should_not be_true }
- with_candidate('quoted cmd in filename', :candidate => '"C:\Program Files\parse_cmd.exe"') { should_not be_true }
+ with_candidate('invalid quoted .bat file', :candidate => '"C:\Program Files\autoexecbat"') { is_expected.not_to be_truthy }
+ with_candidate('invalid quoted .cmd file', :candidate => '"C:\Program Files\autoexeccmd"') { is_expected.not_to be_truthy }
+ with_candidate('quoted bat in filename', :candidate => '"C:\Program Files\abattoir.exe"') { is_expected.not_to be_truthy }
+ with_candidate('quoted cmd in filename', :candidate => '"C:\Program Files\parse_cmd.exe"') { is_expected.not_to be_truthy }
end
describe '#command_to_run' do
@@ -147,15 +147,15 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
let(:shell_out) { Mixlib::ShellOut.new(cmd) }
let(:utils) { Mixlib::ShellOut::Windows::Utils }
- let(:with_valid_exe_at_location) { lambda { |s| utils.stub!(:find_executable).and_return(executable_path) } }
- let(:with_invalid_exe_at_location) { lambda { |s| utils.stub!(:find_executable).and_return(nil) } }
+ let(:with_valid_exe_at_location) { lambda { |s| allow(utils).to receive(:find_executable).and_return(executable_path) } }
+ let(:with_invalid_exe_at_location) { lambda { |s| allow(utils).to receive(:find_executable).and_return(nil) } }
context 'with empty command' do
let(:stubbed_shell_out) { shell_out }
let(:cmd) { ' ' }
it 'should return with a nil executable' do
- should eql([nil, cmd])
+ is_expected.to eql([nil, cmd])
end
end
@@ -172,14 +172,14 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
context 'with executable path enclosed in double quotes' do
it 'should use specified batch file' do
- should eql([cmd_exe, cmd_invocation])
+ is_expected.to eql([cmd_exe, cmd_invocation])
end
context 'with arguments' do
let(:cmd) { "#{executable_path} arguments" }
it 'should use specified executable' do
- should eql([cmd_exe, cmd_invocation])
+ is_expected.to eql([cmd_exe, cmd_invocation])
end
end
@@ -187,7 +187,7 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
let(:cmd) { "#{executable_path} /i \"C:\Program Files (x86)\NUnit 2.6\bin\framework\nunit.framework.dll\"" }
it 'should use specified executable' do
- should eql([cmd_exe, cmd_invocation])
+ is_expected.to eql([cmd_exe, cmd_invocation])
end
end
end
@@ -200,14 +200,14 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
context 'with executable path enclosed in double quotes' do
it 'should use specified batch file' do
- should eql([cmd_exe, cmd_invocation])
+ is_expected.to eql([cmd_exe, cmd_invocation])
end
context 'with arguments' do
let(:cmd) { "#{executable_path} arguments" }
it 'should use specified executable' do
- should eql([cmd_exe, cmd_invocation])
+ is_expected.to eql([cmd_exe, cmd_invocation])
end
end
@@ -215,7 +215,7 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
let(:cmd) { "#{executable_path} /i \"C:\Program Files (x86)\NUnit 2.6\bin\framework\nunit.framework.dll\"" }
it 'should use specified executable' do
- should eql([cmd_exe, cmd_invocation])
+ is_expected.to eql([cmd_exe, cmd_invocation])
end
end
end
@@ -231,14 +231,14 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
let(:executable_path) { 'C:\RUBY192\bin\ruby.exe' }
it 'should use specified executable' do
- should eql([executable_path, cmd])
+ is_expected.to eql([executable_path, cmd])
end
context 'with arguments' do
let(:cmd) { "#{executable_path} arguments" }
it 'should use specified executable' do
- should eql([executable_path, cmd])
+ is_expected.to eql([executable_path, cmd])
end
end
@@ -246,7 +246,7 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
let(:cmd) { "#{executable_path} -e \"print 'fee fie foe fum'\"" }
it 'should use specified executable' do
- should eql([executable_path, cmd])
+ is_expected.to eql([executable_path, cmd])
end
end
end
@@ -257,14 +257,14 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
let(:executable_path) { '"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe"' }
it 'should use specified executable' do
- should eql([executable_path, cmd])
+ is_expected.to eql([executable_path, cmd])
end
context 'with arguments' do
let(:cmd) { "#{executable_path} arguments" }
it 'should use specified executable' do
- should eql([executable_path, cmd])
+ is_expected.to eql([executable_path, cmd])
end
end
@@ -272,7 +272,7 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
let(:cmd) { "#{executable_path} /i \"C:\Program Files (x86)\NUnit 2.6\bin\framework\nunit.framework.dll\"" }
it 'should use specified executable' do
- should eql([executable_path, cmd])
+ is_expected.to eql([executable_path, cmd])
end
end
end