diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-03-16 16:41:24 -0700 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2020-03-23 13:55:01 -0700 |
commit | 8cf05f924432584b28df52cf961e19bef9cb8960 (patch) | |
tree | 8768bd7a115addc65db750a3ea43ab5e63f3c00c | |
parent | 7d5642cc9e3b0ab3bbfcf6e1fc0fe234ac59fbfc (diff) | |
download | chef-8cf05f924432584b28df52cf961e19bef9cb8960.tar.gz |
Change the default value for :rubygems_url to be nil.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r-- | chef-config/lib/chef-config/config.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/package/rubygems.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/package/rubygems_spec.rb | 16 |
3 files changed, 10 insertions, 10 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 0e89a9550c..9c8614559d 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -1219,7 +1219,7 @@ module ChefConfig default :ruby_encoding, Encoding::UTF_8 # can be set to a string or array of strings for URIs to set as rubygems sources - default :rubygems_url, "https://www.rubygems.org" + default :rubygems_url, nil # globally sets the default of the clear_sources property on the gem_package and chef_gem resources default :clear_gem_sources, nil diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index cda2c623e6..8b67006336 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -485,7 +485,7 @@ class Chef def gem_sources srcs = [ new_resource.source ] - srcs << Chef::Config[:rubygems_url] if new_resource.include_default_source + srcs << (Chef::Config[:rubygems_url] || "https://www.rubygems.org") if new_resource.include_default_source srcs.flatten.compact end diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index 295e5f9bf9..2d3f0771c0 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -585,7 +585,7 @@ describe Chef::Provider::Package::Rubygems do it "determines the candidate version by querying the remote gem servers" do expect(provider.gem_env).to receive(:candidate_version_from_remote) - .with(gem_dep, source, Chef::Config[:rubygems_url]) + .with(gem_dep, source, "https://www.rubygems.org") .and_return(Gem::Version.new(target_version)) expect(provider.candidate_version).to eq(target_version) end @@ -605,7 +605,7 @@ describe Chef::Provider::Package::Rubygems do it "determines the candidate version by querying the remote gem servers" do expect(provider.gem_env).to receive(:candidate_version_from_remote) - .with(gem_dep, *[source, Chef::Config[:rubygems_url] ].flatten) + .with(gem_dep, *[source, "https://www.rubygems.org" ].flatten) .and_return(Gem::Version.new(target_version)) expect(provider.candidate_version).to eq(target_version) end @@ -645,13 +645,13 @@ describe Chef::Provider::Package::Rubygems do before do expected_source = [ source ] - expected_source << Chef::Config[:rubygems_url] if include_default_source + expected_source << "https://www.rubygems.org" if include_default_source allow(provider.gem_env).to receive(:candidate_version_from_remote).with(gem_dep, *expected_source.flatten.compact).and_return(version) end describe "in the current gem environment" do it "installs the gem via the gems api when no explicit options are used" do - expect(provider.gem_env).to receive(:install).with(gem_dep, sources: [ Chef::Config[:rubygems_url] ]) + expect(provider.gem_env).to receive(:install).with(gem_dep, sources: [ "https://www.rubygems.org" ]) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -660,7 +660,7 @@ describe Chef::Provider::Package::Rubygems do let(:source) { "http://gems.example.org" } it "installs the gem via the gems api" do - expect(provider.gem_env).to receive(:install).with(gem_dep, sources: [source, Chef::Config[:rubygems_url]]) + expect(provider.gem_env).to receive(:install).with(gem_dep, sources: [source, "https://www.rubygems.org"]) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -691,7 +691,7 @@ describe Chef::Provider::Package::Rubygems do it "installs the gem via the gems api, when the package has no file separator characters in it, but a matching file exists in cwd" do allow(::File).to receive(:exist?).and_return(true) new_resource.package_name("rspec-core") - expect(provider.gem_env).to receive(:install).with(gem_dep, sources: [ Chef::Config[:rubygems_url] ]) + expect(provider.gem_env).to receive(:install).with(gem_dep, sources: [ "https://www.rubygems.org" ]) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -828,7 +828,7 @@ describe Chef::Provider::Package::Rubygems do let(:options) { { install_dir: "/alt/install/location" } } it "installs the gem via the gems api when options are given as a Hash" do - expect(provider.gem_env).to receive(:install).with(gem_dep, { sources: [ Chef::Config[:rubygems_url] ] }.merge(options)) + expect(provider.gem_env).to receive(:install).with(gem_dep, { sources: [ "https://www.rubygems.org" ] }.merge(options)) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end @@ -838,7 +838,7 @@ describe Chef::Provider::Package::Rubygems do let(:target_version) { "9000.0.2" } it "installs the gem via the gems api" do - expect(provider.gem_env).to receive(:install).with(gem_dep, sources: [ Chef::Config[:rubygems_url] ] ) + expect(provider.gem_env).to receive(:install).with(gem_dep, sources: [ "https://www.rubygems.org" ] ) provider.run_action(:install) expect(new_resource).to be_updated_by_last_action end |