diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-03-17 16:10:53 -0700 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2020-03-23 13:55:01 -0700 |
commit | 2658a90aca4d3fd64cea7cb7a52298ebaa0accd6 (patch) | |
tree | a1f3c19efdec620fbacc5b3685719d3107850dbb /spec/unit | |
parent | 5ea527cd5374dbe9a61fa1fbaf0e7d89ac59e8b2 (diff) | |
download | chef-2658a90aca4d3fd64cea7cb7a52298ebaa0accd6.tar.gz |
Clear sources if either a source or rubygems_url is set.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/provider/package/rubygems_spec.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index 63fc0231cd..d2a480cbb0 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -731,7 +731,7 @@ describe Chef::Provider::Package::Rubygems do it "installs the gem with rubygems.org as an added source" do Chef::Config[:rubygems_url] = "https://mirror1" expect(provider.gem_env).to receive(:candidate_version_from_remote).with(gem_dep, Chef::Config[:rubygems_url]).and_return(version) - expected = "#{gem_binary} install rspec-core -q --no-document -v \"#{target_version}\" --source=https://mirror1" + expected = "#{gem_binary} install rspec-core -q --no-document -v \"#{target_version}\" --clear-sources --source=https://mirror1" expect(provider).to receive(:shell_out_compacted!).with(expected, env: nil, timeout: 900) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action @@ -1036,4 +1036,24 @@ describe Chef::Provider::Package::Rubygems, "clear_sources?" do expect(provider.clear_sources?).to be true end end + + context "when Chef::Config[:rubygems_url] is set" do + before do + Chef::Config.rubygems_url = "https://example.com/" + end + + it "is true when clear_sources is unset" do + expect(provider.clear_sources?).to be true + end + + it "is false when clear_sources is set false" do + new_resource.clear_sources(false) + expect(provider.clear_sources?).to be false + end + + it "is true when clear_sources is set true" do + new_resource.clear_sources(true) + expect(provider.clear_sources?).to be true + end + end end |