diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-06-22 17:20:43 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-07-19 13:10:39 -0500 |
commit | 8ccf49c3b4a086f1e0cad2130dc30c04304175b7 (patch) | |
tree | de546229a7f32d7d3e0d5adf9699001f2b1a8057 /spec | |
parent | 04fd47b1221edabbb46caf34798e5340bc46e1ec (diff) | |
download | bundler-8ccf49c3b4a086f1e0cad2130dc30c04304175b7.tar.gz |
[Settings] Stop remembering CLI options in Bundler 2
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/settings_spec.rb | 38 | ||||
-rw-r--r-- | spec/bundler/source/git/git_proxy_spec.rb | 8 | ||||
-rw-r--r-- | spec/bundler/source/rubygems/remote_spec.rb | 18 | ||||
-rw-r--r-- | spec/bundler/source_list_spec.rb | 2 | ||||
-rw-r--r-- | spec/quality_spec.rb | 2 | ||||
-rw-r--r-- | spec/runtime/executable_spec.rb | 6 |
6 files changed, 38 insertions, 36 deletions
diff --git a/spec/bundler/settings_spec.rb b/spec/bundler/settings_spec.rb index 378013c444..7446e7e51e 100644 --- a/spec/bundler/settings_spec.rb +++ b/spec/bundler/settings_spec.rb @@ -40,7 +40,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow before do hash.each do |key, value| - settings[key] = value + settings.set_local key, value end end @@ -100,12 +100,12 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow context "when is boolean" do it "returns a boolean" do - settings[:frozen] = "true" + settings.set_local :frozen, "true" expect(settings[:frozen]).to be true end context "when specific gem is configured" do it "returns a boolean" do - settings["ignore_messages.foobar"] = "true" + settings.set_local "ignore_messages.foobar", "true" expect(settings["ignore_messages.foobar"]).to be true end end @@ -113,7 +113,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow context "when is number" do it "returns a number" do - settings[:ssl_verify_mode] = "1" + settings.set_local :ssl_verify_mode, "1" expect(settings[:ssl_verify_mode]).to be 1 end end @@ -122,7 +122,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow it "raises an PermissionError with explanation" do expect(bundler_fileutils).to receive(:mkdir_p).with(settings.send(:local_config_file).dirname). and_raise(Errno::EACCES) - expect { settings[:frozen] = "1" }. + expect { settings.set_local :frozen, "1" }. to raise_error(Bundler::PermissionError, /config/) end end @@ -130,7 +130,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow describe "#temporary" do it "reset after used" do - Bundler.settings[:no_install] = true + Bundler.settings.set_local :no_install, true Bundler.settings.temporary(:no_install => false) do expect(Bundler.settings[:no_install]).to eq false @@ -147,7 +147,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow context "when called without a block" do it "leaves the setting changed" do Bundler.settings.temporary(:foo => :random) - expect(Bundler.settings[:foo]).to eq :random + expect(Bundler.settings[:foo]).to eq "random" end it "returns nil" do @@ -193,7 +193,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow context "with a configured mirror" do let(:mirror_uri) { URI("https://rubygems-mirror.org/") } - before { settings["mirror.https://rubygems.org/"] = mirror_uri.to_s } + before { settings.set_local "mirror.https://rubygems.org/", mirror_uri.to_s } it "returns the mirror URI" do expect(settings.mirror_for(uri)).to eq(mirror_uri) @@ -240,7 +240,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow end context "with credentials configured by URL" do - before { settings["https://gemserver.example.org/"] = credentials } + before { settings.set_local "https://gemserver.example.org/", credentials } it "returns the configured credentials" do expect(settings.credentials_for(uri)).to eq(credentials) @@ -248,7 +248,7 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow end context "with credentials configured by hostname" do - before { settings["gemserver.example.org"] = credentials } + before { settings.set_local "gemserver.example.org", credentials } it "returns the configured credentials" do expect(settings.credentials_for(uri)).to eq(credentials) @@ -258,49 +258,49 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow describe "URI normalization" do it "normalizes HTTP URIs in credentials configuration" do - settings["http://gemserver.example.org"] = "username:password" + settings.set_local "http://gemserver.example.org", "username:password" expect(settings.all).to include("http://gemserver.example.org/") end it "normalizes HTTPS URIs in credentials configuration" do - settings["https://gemserver.example.org"] = "username:password" + settings.set_local "https://gemserver.example.org", "username:password" expect(settings.all).to include("https://gemserver.example.org/") end it "normalizes HTTP URIs in mirror configuration" do - settings["mirror.http://rubygems.org"] = "http://rubygems-mirror.org" + settings.set_local "mirror.http://rubygems.org", "http://rubygems-mirror.org" expect(settings.all).to include("mirror.http://rubygems.org/") end it "normalizes HTTPS URIs in mirror configuration" do - settings["mirror.https://rubygems.org"] = "http://rubygems-mirror.org" + settings.set_local "mirror.https://rubygems.org", "http://rubygems-mirror.org" expect(settings.all).to include("mirror.https://rubygems.org/") end it "does not normalize other config keys that happen to contain 'http'" do - settings["local.httparty"] = home("httparty") + settings.set_local "local.httparty", home("httparty") expect(settings.all).to include("local.httparty") end it "does not normalize other config keys that happen to contain 'https'" do - settings["local.httpsmarty"] = home("httpsmarty") + settings.set_local "local.httpsmarty", home("httpsmarty") expect(settings.all).to include("local.httpsmarty") end it "reads older keys without trailing slashes" do - settings["mirror.https://rubygems.org"] = "http://rubygems-mirror.org" + settings.set_local "mirror.https://rubygems.org", "http://rubygems-mirror.org" expect(settings.mirror_for("https://rubygems.org/")).to eq( URI("http://rubygems-mirror.org/") ) end it "normalizes URIs with a fallback_timeout option" do - settings["mirror.https://rubygems.org/.fallback_timeout"] = "true" + settings.set_local "mirror.https://rubygems.org/.fallback_timeout", "true" expect(settings.all).to include("mirror.https://rubygems.org/.fallback_timeout") end it "normalizes URIs with a fallback_timeout option without a trailing slash" do - settings["mirror.https://rubygems.org.fallback_timeout"] = "true" + settings.set_local "mirror.https://rubygems.org.fallback_timeout", "true" expect(settings.all).to include("mirror.https://rubygems.org/.fallback_timeout") end end diff --git a/spec/bundler/source/git/git_proxy_spec.rb b/spec/bundler/source/git/git_proxy_spec.rb index e7187082ea..d282a449a5 100644 --- a/spec/bundler/source/git/git_proxy_spec.rb +++ b/spec/bundler/source/git/git_proxy_spec.rb @@ -6,25 +6,25 @@ RSpec.describe Bundler::Source::Git::GitProxy do context "with configured credentials" do it "adds username and password to URI" do - Bundler.settings[uri] = "u:p" + Bundler.settings.temporary(uri => "u:p") expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git")) subject.checkout end it "adds username and password to URI for host" do - Bundler.settings["github.com"] = "u:p" + Bundler.settings.temporary("github.com" => "u:p") expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git")) subject.checkout end it "does not add username and password to mismatched URI" do - Bundler.settings["https://u:p@github.com/bundler/bundler-mismatch.git"] = "u:p" + Bundler.settings.temporary("https://u:p@github.com/bundler/bundler-mismatch.git" => "u:p") expect(subject).to receive(:git_retry).with(match(uri)) subject.checkout end it "keeps original userinfo" do - Bundler.settings["github.com"] = "u:p" + Bundler.settings.temporary("github.com" => "u:p") original = "https://orig:info@github.com/bundler/bundler.git" subject = described_class.new(Pathname("path"), original, "HEAD") expect(subject).to receive(:git_retry).with(match(original)) diff --git a/spec/bundler/source/rubygems/remote_spec.rb b/spec/bundler/source/rubygems/remote_spec.rb index 539360d067..1aa008f3bb 100644 --- a/spec/bundler/source/rubygems/remote_spec.rb +++ b/spec/bundler/source/rubygems/remote_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Bundler::Source::Rubygems::Remote do end it "applies configured credentials" do - Bundler.settings[uri_no_auth.to_s] = credentials + Bundler.settings.temporary(uri_no_auth.to_s => credentials) expect(remote(uri_no_auth).uri).to eq(uri_with_auth) end end @@ -33,7 +33,7 @@ RSpec.describe Bundler::Source::Rubygems::Remote do end it "does not apply given credentials" do - Bundler.settings[uri_no_auth.to_s] = credentials + Bundler.settings.temporary(uri_no_auth.to_s => credentials) expect(remote(uri_no_auth).anonymized_uri).to eq(uri_no_auth) end end @@ -44,7 +44,7 @@ RSpec.describe Bundler::Source::Rubygems::Remote do end it "only applies the given user" do - Bundler.settings[uri_no_auth.to_s] = credentials + Bundler.settings.temporary(uri_no_auth.to_s => credentials) expect(remote(uri_no_auth).cache_slug).to eq("gems.example.com.username.443.MD5HEX(gems.example.com.username.443./)") end end @@ -57,7 +57,7 @@ RSpec.describe Bundler::Source::Rubygems::Remote do end it "does not apply configured credentials" do - Bundler.settings[uri_no_auth.to_s] = "other:stuff" + Bundler.settings.temporary(uri_no_auth.to_s => "other:stuff") expect(remote(uri_with_auth).uri).to eq(uri_with_auth) end end @@ -68,7 +68,7 @@ RSpec.describe Bundler::Source::Rubygems::Remote do end it "does not apply given credentials" do - Bundler.settings[uri_no_auth.to_s] = "other:stuff" + Bundler.settings.temporary(uri_no_auth.to_s => "other:stuff") expect(remote(uri_with_auth).anonymized_uri).to eq(uri_no_auth) end end @@ -79,7 +79,7 @@ RSpec.describe Bundler::Source::Rubygems::Remote do end it "does not apply given credentials" do - Bundler.settings[uri_with_auth.to_s] = credentials + Bundler.settings.temporary(uri_with_auth.to_s => credentials) expect(remote(uri_with_auth).cache_slug).to eq("gems.example.com.username.443.MD5HEX(gems.example.com.username.443./)") end end @@ -106,7 +106,7 @@ RSpec.describe Bundler::Source::Rubygems::Remote do let(:mirror_uri_with_auth) { URI("https://username:password@rubygems-mirror.org/") } let(:mirror_uri_no_auth) { URI("https://rubygems-mirror.org/") } - before { Bundler.settings["mirror.https://rubygems.org/"] = mirror_uri_with_auth.to_s } + before { Bundler.settings.set_local("mirror.https://rubygems.org/", mirror_uri_with_auth.to_s) } specify "#uri returns the mirror URI with credentials" do expect(remote(uri).uri).to eq(mirror_uri_with_auth) @@ -131,8 +131,8 @@ RSpec.describe Bundler::Source::Rubygems::Remote do let(:mirror_uri_no_auth) { URI("https://rubygems-mirror.org/") } before do - Bundler.settings["mirror.https://rubygems.org/"] = mirror_uri_no_auth.to_s - Bundler.settings[mirror_uri_no_auth.to_s] = credentials + Bundler.settings.temporary("mirror.https://rubygems.org/" => mirror_uri_no_auth.to_s) + Bundler.settings.temporary(mirror_uri_no_auth.to_s => credentials) end specify "#uri returns the mirror URI with credentials" do diff --git a/spec/bundler/source_list_spec.rb b/spec/bundler/source_list_spec.rb index 915b638a46..ce3353012c 100644 --- a/spec/bundler/source_list_spec.rb +++ b/spec/bundler/source_list_spec.rb @@ -85,7 +85,7 @@ RSpec.describe Bundler::SourceList do end it "ignores git protocols on request" do - Bundler.settings["git.allow_insecure"] = true + Bundler.settings.temporary(:"git.allow_insecure" => true) expect(Bundler.ui).to_not receive(:warn).with(msg) source_list.add_git_source("uri" => "git://existing-git.org/path.git") end diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index 8c90b33158..dcc518dce4 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -173,6 +173,7 @@ RSpec.describe "The library itself" do console_command default_cli_command deployment_means_frozen + forget_cli_options gem.coc gem.mit inline @@ -185,6 +186,7 @@ RSpec.describe "The library itself" do Bundler::Settings::BOOL_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::BOOL_KEYS" } Bundler::Settings::NUMBER_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::NUMBER_KEYS" } + Bundler::Settings::ARRAY_KEYS.each {|k| all_settings[k] << "in Bundler::Settings::ARRAY_KEYS" } Dir.chdir(root) do key_pattern = /([a-z\._-]+)/i diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb index 5b5dbcdf05..ae3b429b9d 100644 --- a/spec/runtime/executable_spec.rb +++ b/spec/runtime/executable_spec.rb @@ -100,13 +100,13 @@ RSpec.describe "Running bin/* commands" do end it "allows you to stop installing binstubs" do - bundle "install --binstubs bin/" + bundle! "install --binstubs bin/" bundled_app("bin/rackup").rmtree - bundle "install --binstubs \"\"" + bundle! "install --binstubs \"\"" expect(bundled_app("bin/rackup")).not_to exist - bundle "config bin" + bundle! "config bin" expect(out).to include("You have not configured a value for `bin`") end |