summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-07-14 17:10:35 -0700
committerTim Smith <tsmith84@gmail.com>2020-07-15 12:33:13 -0700
commitd8ec5d264a8b76479e6a57ccf838175ffcfeeb5c (patch)
treeedebc9ce84eff3fc80cbc2e7f7bcb264b860edb9 /spec
parentf681ac8e2a96c9f4ba38905054623315f625403b (diff)
downloadchef-d8ec5d264a8b76479e6a57ccf838175ffcfeeb5c.tar.gz
Factor out common test setup.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index 1519890f4a..88d1d460a0 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -106,29 +106,24 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
context "new default rubygems behavior" do
before do
Chef::Config[:rubygems_cache_enabled] = false
+
+ dep_installer = Gem::DependencyInstaller.new
+ expect(dep_installer).not_to receive(:find_gems_with_sources)
+ allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer)
end
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
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