diff options
-rw-r--r-- | lib/bundler/cli.rb | 3 | ||||
-rw-r--r-- | lib/bundler/cli/binstubs.rb | 7 | ||||
-rw-r--r-- | lib/bundler/cli/cache.rb | 6 | ||||
-rw-r--r-- | lib/bundler/cli/check.rb | 6 | ||||
-rw-r--r-- | lib/bundler/cli/common.rb | 4 | ||||
-rw-r--r-- | lib/bundler/cli/install.rb | 55 | ||||
-rw-r--r-- | lib/bundler/cli/package.rb | 8 | ||||
-rw-r--r-- | lib/bundler/cli/update.rb | 2 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 2 | ||||
-rw-r--r-- | lib/bundler/feature_flag.rb | 1 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 93 | ||||
-rw-r--r-- | man/bundle-config.ronn | 5 | ||||
-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 |
18 files changed, 141 insertions, 125 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index c1fc40ab1f..88a079c32e 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -30,7 +30,7 @@ module Bundler Bundler.reset_paths! end - Bundler.settings[:retry] = options[:retry] if options[:retry] + Bundler.settings.set_command_option_if_given :retry, options[:retry] current_cmd = args.last[:current_command].name auto_install if AUTO_INSTALL_CMDS.include?(current_cmd) @@ -38,7 +38,6 @@ module Bundler raise InvalidOption, e.message ensure self.options ||= {} - Bundler.settings.cli_flags_given = !options.empty? unprinted_warnings = Bundler.ui.unprinted_warnings Bundler.ui = UI::Shell.new(options) Bundler.ui.level = "debug" if options["verbose"] diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb index ebb2979625..38863c5e77 100644 --- a/lib/bundler/cli/binstubs.rb +++ b/lib/bundler/cli/binstubs.rb @@ -12,9 +12,10 @@ module Bundler def run Bundler.definition.validate_runtime! - Bundler.settings[:bin] = options["path"] if options["path"] - Bundler.settings[:bin] = nil if options["path"] && options["path"].empty? - Bundler.settings[:shebang] = options["shebang"] if options["shebang"] + path_option = options["path"] + path_option = nil if path_option && path_option.empty? + Bundler.settings.set_command_option :bin, path_option if options["path"] + Bundler.settings.set_command_option_if_given :shebang, options["shebang"] installer = Installer.new(Bundler.root, Bundler.definition) if gems.empty? diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb index 891671447d..77e049e7a2 100644 --- a/lib/bundler/cli/cache.rb +++ b/lib/bundler/cli/cache.rb @@ -11,9 +11,9 @@ module Bundler Bundler.definition.validate_runtime! Bundler.definition.resolve_with_cache! setup_cache_all - Bundler.settings[:cache_all_platforms] = options["all-platforms"] if options.key?("all-platforms") + Bundler.settings.set_command_option_if_given :cache_all_platforms, options["all-platforms"] Bundler.load.cache - Bundler.settings[:no_prune] = true if options["no-prune"] + Bundler.settings.set_command_option_if_given :no_prune, options["no-prune"] Bundler.load.lock rescue GemNotFound => e Bundler.ui.error(e.message) @@ -24,7 +24,7 @@ module Bundler private def setup_cache_all - Bundler.settings[:cache_all] = options[:all] if options.key?("all") + Bundler.settings.set_command_option_if_given :cache_all, options[:all] if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_all] Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \ diff --git a/lib/bundler/cli/check.rb b/lib/bundler/cli/check.rb index 553c48cebf..c7367b2f42 100644 --- a/lib/bundler/cli/check.rb +++ b/lib/bundler/cli/check.rb @@ -9,9 +9,9 @@ module Bundler end def run - if options[:path] - Bundler.settings[:path] = File.expand_path(options[:path]) - Bundler.settings[:disable_shared_gems] = true + if path = options[:path] + Bundler.settings.set_command_option :path, path + Bundler.settings.set_command_option :disable_shared_gems, true end begin diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb index c8c4115fa3..018f7bfdc9 100644 --- a/lib/bundler/cli/common.rb +++ b/lib/bundler/cli/common.rb @@ -15,12 +15,12 @@ module Bundler end def self.output_without_groups_message - return unless Bundler.settings.without.any? + return if Bundler.settings[:without].empty? Bundler.ui.confirm without_groups_message end def self.without_groups_message - groups = Bundler.settings.without + groups = Bundler.settings[:without] group_list = [groups[0...-1].join(", "), groups[-1..-1]]. reject {|s| s.to_s.empty? }.join(" and ") group_str = (groups.size == 1) ? "group" : "groups" diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index b9188b233c..2601803513 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -46,9 +46,9 @@ module Bundler options[:local] = true if Bundler.app_cache.exist? if Bundler.feature_flag.deployment_means_frozen? - Bundler.settings.temporary(:deployment => true) + Bundler.settings.set_command_option :deployment, true else - Bundler.settings[:frozen] ||= true + Bundler.settings.set_command_option :frozen, true end end @@ -152,28 +152,24 @@ module Bundler end def check_trust_policy - if options["trust-policy"] - unless Bundler.rubygems.security_policies.keys.include?(options["trust-policy"]) - Bundler.ui.error "RubyGems doesn't know about trust policy '#{options["trust-policy"]}'. " \ - "The known policies are: #{Bundler.rubygems.security_policies.keys.join(", ")}." - exit 1 - end - Bundler.settings["trust-policy"] = options["trust-policy"] - else - Bundler.settings["trust-policy"] = nil if Bundler.settings["trust-policy"] + trust_policy = options["trust-policy"] + unless Bundler.rubygems.security_policies.keys.unshift(nil).include?(trust_policy) + raise InvalidOption, "RubyGems doesn't know about trust policy '#{trust_policy}'. " \ + "The known policies are: #{Bundler.rubygems.security_policies.keys.join(", ")}." end + Bundler.settings.set_command_option_if_given :"trust-policy", trust_policy end def normalize_groups - Bundler.settings.with = [] if options[:with] && options[:with].empty? - Bundler.settings.without = [] if options[:without] && options[:without].empty? + Bundler.settings.set_command_option_if_given :with, options[:with] + Bundler.settings.set_command_option_if_given :without, options[:without] with = options.fetch("with", []) - with |= Bundler.settings.with.map(&:to_s) + with |= Bundler.settings[:with].map(&:to_s) with -= options[:without] if options[:without] without = options.fetch("without", []) - without |= Bundler.settings.without.map(&:to_s) + without |= Bundler.settings[:without].map(&:to_s) without -= options[:with] if options[:with] options[:with] = with @@ -181,29 +177,30 @@ module Bundler end def normalize_settings - Bundler.settings[:path] = nil if options[:system] - Bundler.settings[:path] = "vendor/bundle" if options[:deployment] - Bundler.settings[:path] = options["path"] if options["path"] - Bundler.settings[:path] ||= "bundle" if options["standalone"] + Bundler.settings.delete(:path) if options[:system] + Bundler.settings.set_command_option :path, "vendor/bundle" if options[:deployment] + Bundler.settings.set_command_option_if_given :path, options["path"] + Bundler.settings.set_command_option :path, "bundle" if options["standalone"] && Bundler.settings[:path].nil? - Bundler.settings[:bin] = options["binstubs"] if options["binstubs"] - Bundler.settings[:bin] = nil if options["binstubs"] && options["binstubs"].empty? + bin_option = options["binstubs"] + bin_option = nil if bin_option && bin_option.empty? + Bundler.settings.set_command_option :bin, bin_option if options["binstubs"] - Bundler.settings[:shebang] = options["shebang"] if options["shebang"] + Bundler.settings.set_command_option_if_given :shebang, options["shebang"] - Bundler.settings[:jobs] = options["jobs"] if options["jobs"] + Bundler.settings.set_command_option_if_given :jobs, options["jobs"] - Bundler.settings[:no_prune] = true if options["no-prune"] + Bundler.settings.set_command_option_if_given :no_prune, options["no-prune"] - Bundler.settings[:no_install] = true if options["no-install"] + Bundler.settings.set_command_option_if_given :no_install, options["no-install"] - Bundler.settings[:clean] = options["clean"] if options["clean"] + Bundler.settings.set_command_option_if_given :clean, options["clean"] - Bundler.settings.without = options[:without] unless Bundler.settings.without == options[:without] - Bundler.settings.with = options[:with] unless Bundler.settings.with == options[:with] + Bundler.settings.set_command_option :without, options[:without] unless Bundler.settings[:without] == options[:without] + Bundler.settings.set_command_option :with, options[:with] unless Bundler.settings[:with] == options[:with] disable_shared_gems = Bundler.settings[:path] ? true : nil - Bundler.settings[:disable_shared_gems] = disable_shared_gems unless Bundler.settings[:disable_shared_gems] == disable_shared_gems + Bundler.settings.set_command_option :disable_shared_gems, disable_shared_gems unless Bundler.settings[:disable_shared_gems] == disable_shared_gems end def warn_ambiguous_gems diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb index eca7e08342..9fb4e7f137 100644 --- a/lib/bundler/cli/package.rb +++ b/lib/bundler/cli/package.rb @@ -10,9 +10,9 @@ module Bundler def run Bundler.ui.level = "error" if options[:quiet] - Bundler.settings[:path] = File.expand_path(options[:path]) if options[:path] - Bundler.settings[:cache_all_platforms] = options["all-platforms"] if options.key?("all-platforms") - Bundler.settings[:cache_path] = options["cache-path"] if options.key?("cache-path") + Bundler.settings.set_command_option_if_given :path, options[:path] + Bundler.settings.set_command_option_if_given :cache_all_platforms, options["all-platforms"] + Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"] setup_cache_all install @@ -35,7 +35,7 @@ module Bundler end def setup_cache_all - Bundler.settings[:cache_all] = options[:all] if options.key?("all") + Bundler.settings.set_command_option_if_given :cache_all, options[:all] if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_all] Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \ diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index 952076566f..c2391fa76d 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -56,7 +56,7 @@ module Bundler opts["update"] = true opts["local"] = options[:local] - Bundler.settings[:jobs] = opts["jobs"] if opts["jobs"] + Bundler.settings.set_command_option_if_given :jobs, opts["jobs"] Bundler.definition.validate_runtime! installer = Installer.install Bundler.root, Bundler.definition, opts diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index a8b37499fd..6726cf95e8 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -920,7 +920,7 @@ module Bundler end def requested_groups - groups - Bundler.settings.without - @optional_groups + Bundler.settings.with + groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with] end def lockfiles_equal?(current, proposed, preserve_unknown_sections) diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 00523eb96e..cc130b5d9b 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -46,6 +46,7 @@ module Bundler settings_flag(:suppress_install_using_messages) { bundler_2_mode? } settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? } settings_flag(:update_requires_all_flag) { bundler_2_mode? } + settings_flag(:forget_cli_options) { bundler_2_mode? } settings_option(:default_cli_command) { bundler_2_mode? ? :cli_help : :install } diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 96e67bfdb4..eadc303374 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -25,6 +25,7 @@ module Bundler disable_version_check error_on_stderr force_ruby_platform + forget_cli_options frozen gem.coc gem.mit @@ -54,25 +55,27 @@ module Bundler timeout ].freeze + ARRAY_KEYS = %w[ + with + without + ].freeze + DEFAULT_CONFIG = { :redirect => 5, :retry => 3, :timeout => 10, }.freeze - attr_accessor :cli_flags_given - def initialize(root = nil) @root = root @local_config = load_config(local_config_file) @global_config = load_config(global_config_file) - @cli_flags_given = false @temporary = {} end def [](name) key = key_for(name) - value = @temporary.fetch(name) do + value = @temporary.fetch(key) do @local_config.fetch(key) do ENV.fetch(key) do @global_config.fetch(key) do @@ -83,10 +86,11 @@ module Bundler converted_value(value, name) end - def []=(key, value) - local_config_file || raise(GemfileNotFound, "Could not locate Gemfile") - - if cli_flags_given + def set_command_option(key, value) + if Bundler.feature_flag.forget_cli_options? + temporary(key => value) + value + else command = if value.nil? "bundle config --delete #{key}" else @@ -98,20 +102,32 @@ module Bundler "will no longer be automatically remembered. Instead please set flags " \ "you want remembered between commands using `bundle config " \ "<setting name> <setting value>`, i.e. `#{command}`" + + set_local(key, value) end + end + + def set_command_option_if_given(key, value) + return if value.nil? + set_command_option(key, value) + end + + def set_local(key, value) + local_config_file || raise(GemfileNotFound, "Could not locate Gemfile") set_key(key, value, @local_config, local_config_file) end - alias_method :set_local, :[]= def temporary(update) - existing = Hash[update.map {|k, _| [k, @temporary[k]] }] - @temporary.update(update) + existing = Hash[update.map {|k, _| [k, @temporary[key_for(k)]] }] + update.each do |k, v| + set_key(k, v, @temporary, nil) + end return unless block_given? begin yield ensure - existing.each {|k, v| v.nil? ? @temporary.delete(k) : @temporary[k] = v } + existing.each {|k, v| set_key(k, v, @temporary, nil) } end end @@ -126,7 +142,7 @@ module Bundler def all env_keys = ENV.keys.grep(/\ABUNDLE_.+/) - keys = @global_config.keys | @local_config.keys | env_keys + keys = @temporary.keys | @global_config.keys | @local_config.keys | env_keys keys.map do |key| key.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase @@ -187,22 +203,6 @@ module Bundler locations end - def without=(array) - set_array(:without, array) - end - - def with=(array) - set_array(:with, array) - end - - def without - get_array(:without) - end - - def with - get_array(:with) - end - # @local_config["BUNDLE_PATH"] should be prioritized over ENV["BUNDLE_PATH"] def path key = key_for(:path) @@ -261,28 +261,37 @@ module Bundler end end - def is_num(value) - NUMBER_KEYS.include?(value.to_s) + def is_num(key) + NUMBER_KEYS.include?(key.to_s) + end + + def is_array(key) + ARRAY_KEYS.include?(key.to_s) end - def get_array(key) - self[key] ? self[key].split(":").map(&:to_sym) : [] + def to_array(value) + return [] unless value + value.split(":").map(&:to_sym) end - def set_array(key, array) - self[key] = (array.empty? ? nil : array.join(":")) if array + def array_to_s(array) + array.empty? ? nil : array.join(":") end def set_key(key, value, hash, file) + value = array_to_s(value) if is_array(key) + key = key_for(key) unless hash[key] == value hash[key] = value hash.delete(key) if value.nil? - SharedHelpers.filesystem_access(file) do |p| - FileUtils.mkdir_p(p.dirname) - require "bundler/yaml_serializer" - p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) } + if file + SharedHelpers.filesystem_access(file) do |p| + FileUtils.mkdir_p(p.dirname) + require "bundler/yaml_serializer" + p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) } + end end end @@ -290,14 +299,16 @@ module Bundler end def converted_value(value, key) - if value.nil? + if is_array(key) + to_array(value) + elsif value.nil? nil elsif is_bool(key) || value == "false" to_bool(value) elsif is_num(key) value.to_i else - value + value.to_s end end diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn index 42fb69465a..f1ba87dfd6 100644 --- a/man/bundle-config.ronn +++ b/man/bundle-config.ronn @@ -71,6 +71,9 @@ The options that can be configured are: * `without`: A space-separated list of groups referencing gems to skip during installation. +* `with`: + A space-separated list of groups referencing gems to include during installation. + ## BUILD OPTIONS You can use `bundle config` to give bundler the flags to pass to the gem @@ -253,6 +256,8 @@ learn more about their operation in [bundle install(1)][bundle-install]. and disallow passing no options to `bundle update`. * `user_agent` (`BUNDLE_USER_AGENT`): The custom user agent fragment Bundler includes in API requests. +* `with` (`BUNDLE_WITH`): + A `:`-separated list of groups whose gems bundler should install. * `without` (`BUNDLE_WITHOUT`): A `:`-separated list of groups whose gems bundler should not install. 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 |