summaryrefslogtreecommitdiff
path: root/spec/mixlib/shellout/windows_spec.rb
diff options
context:
space:
mode:
authorMatt Wrock <matt@mattwrock.com>2015-09-11 14:53:13 -0700
committerMatt Wrock <matt@mattwrock.com>2015-09-11 14:53:13 -0700
commitaad254180a12abc1847a1f0c52a43d947e301031 (patch)
tree54f262f75a815839f17499948e34f5e9bddc55d3 /spec/mixlib/shellout/windows_spec.rb
parent9b28d7470c521d737ae12bd71199c906d799bfd1 (diff)
downloadmixlib-shellout-aad254180a12abc1847a1f0c52a43d947e301031.tar.gz
have failing test
Diffstat (limited to 'spec/mixlib/shellout/windows_spec.rb')
-rw-r--r--spec/mixlib/shellout/windows_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/mixlib/shellout/windows_spec.rb b/spec/mixlib/shellout/windows_spec.rb
index d3fb26b..118be75 100644
--- a/spec/mixlib/shellout/windows_spec.rb
+++ b/spec/mixlib/shellout/windows_spec.rb
@@ -159,6 +159,35 @@ describe 'Mixlib::ShellOut::Windows', :windows_only do
end
end
+ context 'with extensionless executable' do
+ let(:stubbed_shell_out) { shell_out }
+ let(:executable_path) { 'C:\Windows\system32/ping.EXE' }
+ let(:cmd) { 'ping' }
+
+ before do
+ allow(ENV).to receive(:[]).with('PATH').and_return('C:\Windows\system32')
+ allow(ENV).to receive(:[]).with('PATHEXT').and_return('.EXE')
+ allow(ENV).to receive(:[]).with('COMSPEC').and_return('C:\Windows\system32\cmd.exe')
+ allow(File).to receive(:executable?).and_return(false)
+ allow(File).to receive(:executable?).with(executable_path).and_return(true)
+ end
+
+ it 'should return with full path with extension' do
+ is_expected.to eql([executable_path, cmd])
+ end
+
+ context 'there is a directory named after command' do
+ before do
+ # File.executable? returns true for directories
+ allow(File).to receive(:executable?).with(cmd).and_return(true)
+ end
+
+ it 'should return with full path with extension' do
+ is_expected.to eql([executable_path, cmd])
+ end
+ end
+ end
+
context 'with batch files' do
let(:stubbed_shell_out) { shell_out.tap(&with_valid_exe_at_location) }
let(:cmd_invocation) { "cmd /c \"#{cmd}\"" }