diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2018-03-07 18:06:53 -0800 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2018-03-07 18:06:53 -0800 |
commit | cdfc049ed10113cb8e69da20a65b8a6a87f68564 (patch) | |
tree | bf19ff905eb2f3c3e23589a61de6f94c12c2b93c /spec | |
parent | 4cba16e0cbc7450b00d14f01b3d43f2a6b561e4a (diff) | |
download | chef-cdfc049ed10113cb8e69da20a65b8a6a87f68564.tar.gz |
Fix up stubs for the new installed_versions.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Diffstat (limited to 'spec')
-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 |