summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2017-05-16 11:41:27 +0100
committerGitHub <noreply@github.com>2017-05-16 11:41:27 +0100
commitef44e5bd88682bf783b58ce665f4fb7d6bd76dd8 (patch)
treecbe41b48ce1493c24252084b6c28957c4457f92a /spec
parent90f3336232f76c10de6eeaddb59d3f4080eaa384 (diff)
parent48cd11446ab14c425b3da0fa744d4f4ed11b2f73 (diff)
downloadchef-ef44e5bd88682bf783b58ce665f4fb7d6bd76dd8.tar.gz
Merge pull request #6154 from chef/tm/gem_path
Ensure that we check the embedded gem binary last
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index c40eed50cf..9f19e3602f 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -338,7 +338,7 @@ describe Chef::Provider::Package::Rubygems do
let(:target_version) { nil }
let(:gem_name) { "rspec-core" }
let(:gem_binary) { nil }
- let(:bindir) { "/usr/bin/ruby" }
+ let(:bindir) { "/usr/bin" }
let(:options) { nil }
let(:source) { nil }
let(:include_default_source) { true }
@@ -372,6 +372,8 @@ describe Chef::Provider::Package::Rubygems do
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(bindir)
# Rubygems uses this interally
allow(RbConfig::CONFIG).to receive(:[]).with("arch").and_call_original
+ allow(File).to receive(:executable?).and_return false
+ allow(File).to receive(:executable?).with("#{bindir}/gem").and_return true
end
describe "when new_resource version is nil" do
@@ -439,9 +441,9 @@ describe Chef::Provider::Package::Rubygems do
it "searches for a gem binary when running on Omnibus on Unix" do
platform_mock :unix do
allow(ENV).to receive(:[]).with("PATH").and_return("/usr/bin:/usr/sbin:/opt/chef/embedded/bin")
- allow(File).to receive(:exist?).with("/usr/bin/gem").and_return(false)
- allow(File).to receive(:exist?).with("/usr/sbin/gem").and_return(true)
- allow(File).to receive(:exist?).with("/opt/chef/embedded/bin/gem").and_return(true) # should not get here
+ allow(File).to receive(:executable?).with("/usr/bin/gem").and_return(false)
+ allow(File).to receive(:executable?).with("/usr/sbin/gem").and_return(true)
+ allow(File).to receive(:executable?).with("/opt/chef/embedded/bin/gem").and_return(true) # should not get here
expect(provider.gem_env.gem_binary_location).to eq("/usr/sbin/gem")
end
end
@@ -451,13 +453,14 @@ describe Chef::Provider::Package::Rubygems do
it "searches for a gem binary when running on Omnibus on Windows" do
platform_mock :windows do
- allow(ENV).to receive(:[]).with("PATH").and_return('C:\windows\system32;C:\windows;C:\Ruby186\bin;d:\opscode\chef\embedded\bin')
- allow(File).to receive(:exist?).with('C:\\windows\\system32\\gem').and_return(false)
- allow(File).to receive(:exist?).with('C:\\windows\\gem').and_return(false)
- allow(File).to receive(:exist?).with('C:\\Ruby186\\bin\\gem').and_return(true)
- allow(File).to receive(:exist?).with('d:\\opscode\\chef\\bin\\gem').and_return(false) # should not get here
- allow(File).to receive(:exist?).with('d:\\opscode\\chef\\embedded\\bin\\gem').and_return(false) # should not get here
- expect(provider.gem_env.gem_binary_location).to eq('C:\Ruby186\bin\gem')
+ allow(ENV).to receive(:[]).with("PATH").and_return('C:\windows\system32;C:\windows;C:\Ruby186\bin')
+ allow(File).to receive(:executable?).with('C:\\windows\\system32/gem').and_return(false)
+ allow(File).to receive(:executable?).with('C:\\windows/gem').and_return(false)
+ allow(File).to receive(:executable?).with('C:\\Ruby186\\bin/gem').and_return(true)
+ allow(File).to receive(:executable?).with('d:\\opscode\\chef\\bin/gem').and_return(false) # should not get here
+ allow(File).to receive(:executable?).with('d:\\opscode\\chef\\bin/gem').and_return(false) # should not get here
+ allow(File).to receive(:executable?).with("d:/opscode/chef/embedded/bin/gem").and_return(false) # should not get here
+ expect(provider.gem_env.gem_binary_location).to eq('C:\Ruby186\bin/gem')
end
end
end