diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-08-30 16:36:06 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-08-30 16:36:06 -0500 |
commit | 538dae8cfda9656cb5e2bee14f5b0f1be02cae70 (patch) | |
tree | 0b6e362ed029fec6abbdd69fee60e1105007e28c | |
parent | 9d618dde0a9a733540e5e46cd280829a331e7961 (diff) | |
download | bundler-538dae8cfda9656cb5e2bee14f5b0f1be02cae70.tar.gz |
Add specs for the new config subcommandsseg-cleanup-config
-rw-r--r-- | lib/bundler/cli/config.rb | 4 | ||||
-rw-r--r-- | spec/commands/config_spec.rb | 86 |
2 files changed, 88 insertions, 2 deletions
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index e39b4f138d..cc89465adc 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -31,8 +31,8 @@ module Bundler desc "set NAME VALUE", "Sets the given value for the given key" scope_options - def set(name, *value) - Base.new(options, name, value, self).run + def set(name, value, *value_) + Base.new(options, name, value_.unshift(value), self).run end desc "unset NAME", "Unsets the value for the given key" diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb index 9e49357465..c76135d72c 100644 --- a/spec/commands/config_spec.rb +++ b/spec/commands/config_spec.rb @@ -362,6 +362,92 @@ E expect(out).to match(long_string_without_special_characters) end end + + describe "subcommands" do + it "list" do + bundle! "config list" + expect(last_command.stdout).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\"" + + bundle! "config list", :parseable => true + expect(last_command.stdout).to eq "spec_run=true" + end + + it "get" do + ENV["BUNDLE_BAR"] = "bar_val" + + bundle! "config get foo" + expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + + ENV["BUNDLE_FOO"] = "foo_val" + + bundle! "config get foo --parseable" + expect(last_command.stdout).to eq "foo=foo_val" + + bundle! "config get foo" + expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\"" + end + + it "set" do + bundle! "config set foo 1" + expect(last_command.stdout).to eq "" + + bundle! "config set --local foo 2" + expect(last_command.stdout).to eq "" + + bundle! "config set --global foo 3" + expect(last_command.stdout).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting" + + bundle! "config set --parseable --local foo 4" + expect(last_command.stdout).to eq "foo=4" + + bundle! "config set --local foo 4.1" + expect(last_command.stdout).to eq "You are replacing the current local value of foo, which is currently \"4\"" + + bundle "config set --global --local foo 5" + expect(last_command).to be_failure + expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time." + end + + it "unset" do + bundle! "config unset foo" + expect(last_command.stdout).to eq "" + + bundle! "config set foo 1" + bundle! "config unset foo --parseable" + expect(last_command.stdout).to eq "" + + bundle! "config set --local foo 1" + bundle! "config set --global foo 2" + + bundle! "config unset foo" + expect(last_command.stdout).to eq "" + expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + + bundle! "config set --local foo 1" + bundle! "config set --global foo 2" + + bundle! "config unset foo --local" + expect(last_command.stdout).to eq "" + expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for the current user (#{home(".bundle/config")}): \"2\"" + bundle! "config unset foo --global" + expect(last_command.stdout).to eq "" + expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + + bundle! "config set --local foo 1" + bundle! "config set --global foo 2" + + bundle! "config unset foo --global" + expect(last_command.stdout).to eq "" + expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for your local app (#{bundled_app(".bundle/config")}): \"1\"" + bundle! "config unset foo --local" + expect(last_command.stdout).to eq "" + expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`" + + bundle "config unset foo --local --global" + expect(last_command).to be_failure + expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time." + end + end end RSpec.describe "setting gemfile via config" do |