|
36 | 36 | allow(ENV).to receive(:[]).with('PATHEXT').and_return nil |
37 | 37 | end |
38 | 38 |
|
| 39 | + context 'when using a command aliased to a Powershell command' do |
| 40 | + it 'checks for the alias and returns the original queried command' do |
| 41 | + allow(executor).to receive(:aliased_command?).with('foo.exe').and_return true |
| 42 | + |
| 43 | + expect(executor.which('foo.exe')).to eq 'foo.exe' |
| 44 | + end |
| 45 | + end |
| 46 | + |
39 | 47 | context 'when it is provided with an absolute path' do |
40 | 48 | it 'returns the path to binary if executable' do |
41 | 49 | allow(File).to receive(:executable?).with('C:\Tools\foo.exe').and_return true |
|
66 | 74 | it 'returns the absolute path if found' do |
67 | 75 | allow(File).to receive(:executable?).with('C:\Windows\system32\foo.exe').and_return false |
68 | 76 | allow(File).to receive(:executable?).with('C:\Windows\foo.exe').and_return true |
| 77 | + allow(executor).to receive(:aliased_command?).with('foo.exe').and_return false |
69 | 78 |
|
70 | 79 | expect(executor.which('foo.exe')).to eq 'C:\Windows\foo.exe' |
71 | 80 | end |
72 | 81 |
|
73 | 82 | it "won't check all paths if one is executable" do |
74 | 83 | allow(File).to receive(:executable?).with('C:\Windows\system32\foo.exe').and_return false |
75 | 84 | allow(File).to receive(:executable?).with('C:\Windows\foo.exe').and_return true |
| 85 | + allow(executor).to receive(:aliased_command?).with('foo.exe').and_return false |
76 | 86 |
|
77 | 87 | expect(File).not_to receive(:executable?).with('C:\Windows\System32\Wbem\foo.exe') |
78 | 88 | executor.which('foo.exe') |
|
87 | 97 | allow(File).to receive(:executable?).with('C:\Windows\foo' + ext).and_return false |
88 | 98 | end |
89 | 99 | allow(File).to receive(:executable?).with('C:\Windows\foo.EXE').and_return true |
| 100 | + allow(executor).to receive(:aliased_command?).with('foo').and_return false |
90 | 101 |
|
91 | 102 | expect(executor.which('foo')).to eq 'C:\Windows\foo.EXE' |
92 | 103 | end |
|
95 | 106 | allow(File).to receive(:executable?).with('C:\Windows\system32\foo.exe').and_return false |
96 | 107 | allow(File).to receive(:executable?).with('C:\Windows\foo.exe').and_return false |
97 | 108 | allow(File).to receive(:executable?).with('C:\Windows\System32\Wbem\foo.exe').and_return false |
| 109 | + allow(executor).to receive(:aliased_command?).with('foo.exe').and_return false |
98 | 110 |
|
99 | 111 | expect(executor.which('foo.exe')).to be nil |
100 | 112 | end |
|
0 commit comments