summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2017-05-15 10:52:15 +0100
committerThom May <thom@chef.io>2017-05-16 11:01:15 +0100
commit48cd11446ab14c425b3da0fa744d4f4ed11b2f73 (patch)
treeaae649e65755ebbf83a433ee180c69aa756526f5 /spec
parent013d559b186e760f1f478180a15a5289f49e4849 (diff)
downloadchef-48cd11446ab14c425b3da0fa744d4f4ed11b2f73.tar.gz
Ensure that we check the embedded gem binary lasttm/gem_path
Previously we injected our expected paths in to ENV['PATH'] but we stopped doing that in Chef 13; for gem_package, we need to ensure that if all else fails we'll use the Omnibus provided gem binary, but we should never pick that if we can find a different one. Closes: #6103 Signed-off-by: Thom May <thom@chef.io>
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