diff options
-rw-r--r-- | spec/unit/provider/package/rubygems_spec.rb | 11 |
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 |