Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/utils_spec.rb')
-rw-r--r--spec/lib/gitlab/utils_spec.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/spec/lib/gitlab/utils_spec.rb b/spec/lib/gitlab/utils_spec.rb
index f1601294c07..d756ec5ef83 100644
--- a/spec/lib/gitlab/utils_spec.rb
+++ b/spec/lib/gitlab/utils_spec.rb
@@ -249,10 +249,16 @@ RSpec.describe Gitlab::Utils do
end
describe '.which' do
- it 'finds the full path to an executable binary' do
- expect(File).to receive(:executable?).with('/bin/sh').and_return(true)
+ before do
+ stub_env('PATH', '/sbin:/usr/bin:/home/joe/bin')
+ end
+
+ it 'finds the full path to an executable binary in order of appearance' do
+ expect(File).to receive(:executable?).with('/sbin/tool').ordered.and_return(false)
+ expect(File).to receive(:executable?).with('/usr/bin/tool').ordered.and_return(true)
+ expect(File).not_to receive(:executable?).with('/home/joe/bin/tool')
- expect(which('sh', 'PATH' => '/bin')).to eq('/bin/sh')
+ expect(which('tool')).to eq('/usr/bin/tool')
end
end