summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-03-12 10:29:03 -0700
committerGitHub <noreply@github.com>2018-03-12 10:29:03 -0700
commitfc7550fd5160170561731df5d9a9bda793a12c2f (patch)
tree57a15884abc1e2d83872267ce092410eef87a049 /spec
parentbab1178280a5971a7b33c37df591aaa25bf51f94 (diff)
parentb04570ebafb88f67ae6bb0da95236f6903ef9e49 (diff)
downloadchef-fc7550fd5160170561731df5d9a9bda793a12c2f.tar.gz
Merge pull request #6955 from coderanger/gem-installed-versions
Rework installed_versions for newer Rubygems
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index ac2b511ca9..071cba23d8 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -43,7 +43,10 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
it "determines the installed versions of gems from Gem.source_index" do
gems = [gemspec("rspec-core", Gem::Version.new("1.2.9")), gemspec("rspec-core", Gem::Version.new("1.3.0"))]
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.0")
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
+ expect(Gem::Specification).to receive(:dirs).and_return(["/path/to/gems/specifications", "/another/path/to/gems/specifications"])
+ expect(Gem::Specification).to receive(:installed_stubs).with(["/path/to/gems/specifications", "/another/path/to/gems/specifications"], "rspec-core-*.gemspec").and_return(gems)
+ elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.0")
expect(Gem::Specification).to receive(:find_all_by_name).with("rspec-core", Gem::Dependency.new("rspec-core").requirement).and_return(gems)
else
expect(Gem.source_index).to receive(:search).with(Gem::Dependency.new("rspec-core", nil)).and_return(gems)
@@ -219,7 +222,11 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
it "determines the installed versions of gems from the source index" do
gems = [gemspec("rspec", Gem::Version.new("1.2.9")), gemspec("rspec", Gem::Version.new("1.3.0"))]
rspec_dep = Gem::Dependency.new("rspec", nil)
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.0")
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
+ allow(@gem_env).to receive(:gem_specification).and_return(Gem::Specification)
+ expect(Gem::Specification).to receive(:dirs).and_return(["/path/to/gems/specifications", "/another/path/to/gems/specifications"])
+ expect(Gem::Specification).to receive(:installed_stubs).with(["/path/to/gems/specifications", "/another/path/to/gems/specifications"], "rspec-*.gemspec").and_return(gems)
+ elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.0")
allow(@gem_env).to receive(:gem_specification).and_return(Gem::Specification)
expect(@gem_env.gem_specification).to receive(:find_all_by_name).with(rspec_dep.name, rspec_dep.requirement).and_return(gems)
else