diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-12-14 16:04:24 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-12-14 16:04:24 -0800 |
commit | 28564f2fe2c38e2db0fc81d547f4885cd1da8dd0 (patch) | |
tree | b5511ec66c0b83aa5ce88ac71a259f3567e38b68 | |
parent | 97bcd6f44dcc1f1ed4c57c689ec2798970cd2f88 (diff) | |
download | chef-lcg/rubygems_perf.tar.gz |
savegame of better codelcg/rubygems_perf
-rw-r--r-- | lib/chef/provider/package/rubygems.rb | 7 | ||||
-rw-r--r-- | spec/unit/provider/package/rubygems_spec.rb | 11 |
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index a0ff13e2b6..453c40e417 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -168,12 +168,9 @@ class Chef best_gem && [best_gem.spec, best_gem.source] else # Use the API that 'gem install' calls which does not pull down the rubygems universe - rs = Gem::RequestSet.new - rs.import [ gem_dependency ] begin - # rs.resolve returns the gem which satisfies the dependency along with all of its deps - resolved_spec = rs.resolve.select { |spec| spec.name == gem_dependency.name }.first.spec - resolved_spec && resolved_spec + rs = dependency_installer.resolve_dependencies gem_dependency.name, gem_dependency.requirement + rs.specs.first rescue Gem::UnsatisfiableDependencyError nil end diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index 92806057b9..f2c8e8c4b8 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -92,18 +92,25 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do it "finds a matching gem candidate version on rubygems 2.0.0+" do dep = Gem::Dependency.new('rspec', '>= 0') + dep_installer = Gem::DependencyInstaller.new + allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer) + expect(dep_installer).not_to receive(:find_gems_with_sources).with(dep).and_call_original expect(@gem_env.candidate_version_from_remote(dep)).to be_kind_of(Gem::Version) end it "gives the candidate version as nil if none is found" do dep = Gem::Dependency.new('lksdjflksdjflsdkfj', '>= 0') + dep_installer = Gem::DependencyInstaller.new + allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer) + expect(dep_installer).not_to receive(:find_gems_with_sources).with(dep).and_call_original expect(@gem_env.candidate_version_from_remote(dep)).to be_nil end it "finds a matching gem from a specific gemserver when explicit sources are given (to a server that doesn't respond to api requests)" do - # this test is expensive because it really hits the s3 bucket, which doesn't respond to the REST API so it falls back and downloads - # all the specs, and then inflates them all into objects. dep = Gem::Dependency.new('rspec', '>= 0') + dep_installer = Gem::DependencyInstaller.new + allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer) + expect(dep_installer).not_to receive(:find_gems_with_sources).with(dep).and_call_original expect(@gem_env.candidate_version_from_remote(dep, 'http://production.cf.rubygems.org')).to be_kind_of(Gem::Version) end end |