summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Lance <stefan@lances.net>2015-08-19 15:01:43 -0500
committerStefan Lance <stefan@lances.net>2015-08-19 15:12:09 -0500
commit8cf8daaaf422172a1501bb20b6e6cb7e18d4ca47 (patch)
tree573618df7cd36955f51364394166ce9e31da6342
parent0045744f0fe54bfa3341387eadaaf487391973d8 (diff)
downloadbundler-8cf8daaaf422172a1501bb20b6e6cb7e18d4ca47.tar.gz
Fix failing config_spec.rb specs [wip]
-rw-r--r--lib/bundler/cli/config.rb33
-rw-r--r--spec/commands/config_spec.rb20
2 files changed, 40 insertions, 13 deletions
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb
index f041681377..aaefb1beb4 100644
--- a/lib/bundler/cli/config.rb
+++ b/lib/bundler/cli/config.rb
@@ -153,9 +153,14 @@ module Bundler
if (name == "with") && ((Bundler.settings.without(:local).include?(group) && scope == "local") || (Bundler.settings.without(:global).include?(group) && scope == "global"))
- # TODO: include the scopes of the old setting in the messages below
+ if Bundler.settings.without(:local).include?(group) && scope == "local"
+ without_scope = "locally"
+ else
+ without_scope = "globally"
+ end
+
Bundler.ui.info "`with` and `without` settings cannot share groups. "\
- "You have already set `without #{new_value}`, so it will be unset."
+ "You have already set `without #{new_value}` #{without_scope}, so it will be unset."
difference = Bundler.settings.without - [group]
if difference == []
@@ -167,8 +172,14 @@ module Bundler
:conflict
elsif (name == "without") && ((Bundler.settings.with(:local).include?(group) && scope == "local") || (Bundler.settings.with(:global).include?(group) && scope == "global"))
+ if Bundler.settings.with(:local).include?(group) && scope == "local"
+ with_scope = "locally"
+ else
+ with_scope = "globally"
+ end
+
Bundler.ui.info "`with` and `without` settings cannot share groups. "\
- "You have already set `with #{new_value}`, so it will be unset."
+ "You have already set `with #{new_value}` #{with_scope}, so it will be unset."
Bundler.settings.with = Bundler.settings.with - [group]
difference = Bundler.settings.with - [group]
@@ -197,5 +208,21 @@ module Bundler
Bundler.settings.set_local(name, nil) unless scope == "global"
Bundler.settings.set_global(name, nil) unless scope == "local"
end
+
+ # def with_conflict?(group, scope)
+ # if scope == :local
+ # Bundler.settings.with(:local).include?(group) && scope == "local"
+ # elsif scope == :global
+ # Bundler.settings.with(:global).include?(group) && scope == "global"
+ # end
+ # end
+
+ # def without_conflict?(group, scope)
+ # if scope == :local
+ # Bundler.settings.without(:local).include?(group) && scope == "local"
+ # elsif scope == :global
+ # Bundler.settings.without(:global).include?(group) && scope == "global"
+ # end
+ # end
end
end
diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb
index 8abd4360da..b5e8242ed1 100644
--- a/spec/commands/config_spec.rb
+++ b/spec/commands/config_spec.rb
@@ -376,7 +376,7 @@ describe "setting `with` and `without` options" do
bundle "config with foo"
bundle "config without foo"
- expect(out).to include("already set `with foo`, so it will be unset.")
+ expect(out).to include("already set `with foo` globally, so it will be unset.")
expect(Bundler.settings.with).to eq([])
end
end
@@ -387,7 +387,7 @@ describe "setting `with` and `without` options" do
it "prints a message" do
bundle "config without foo"
bundle "config with foo"
- expect(out).to include("already set `without foo`, so it will be unset.")
+ expect(out).to include("already set `without foo` globally, so it will be unset.")
expect(Bundler.settings.without).to eq([])
end
@@ -402,7 +402,7 @@ describe "setting `with` and `without` options" do
it "prints a message" do
bundle "config --local without foo"
- # expect(out).to include("already set `with foo --local`, so it will be unset.")
+ expect(out).to include("already set `with foo` locally, so it will be unset.")
expect(Bundler.settings.with).to eq([])
end
end
@@ -411,7 +411,7 @@ describe "setting `with` and `without` options" do
it "does not print a message" do
bundle "config --global without foo"
- # expect(out).not_to include("already set `with foo --local`, so it will be unset.")
+ expect(out).not_to include("already set `with foo` locally, so it will be unset.")
expect(Bundler.settings.with).not_to eq([])
end
end
@@ -424,7 +424,7 @@ describe "setting `with` and `without` options" do
it "does not print a message" do
bundle "config --local without foo"
- # expect(out).not_to include("already set `with foo --global`, so it will be unset.")
+ expect(out).not_to include("already set `with foo` globally, so it will be unset.")
expect(Bundler.settings.with).not_to eq([])
end
end
@@ -433,7 +433,7 @@ describe "setting `with` and `without` options" do
it "prints a message" do
bundle "config without foo --global"
- # expect(out).to include("already set `with foo --global`, so it will be unset.")
+ expect(out).to include("already set `with foo` globally, so it will be unset.")
expect(Bundler.settings.with).to eq([])
end
end
@@ -446,7 +446,7 @@ describe "setting `with` and `without` options" do
it "prints a message" do
bundle "config --local with foo"
- # expect(out).to include("already set `without foo --local`, so it will be unset.")
+ expect(out).to include("already set `without foo` locally, so it will be unset.")
expect(Bundler.settings.without).to eq([])
end
end
@@ -455,7 +455,7 @@ describe "setting `with` and `without` options" do
it "does not print a message" do
bundle "config --global with foo"
- # expect(out).not_to include("already set `without foo --local`, so it will be unset.")
+ expect(out).not_to include("already set `without foo` locally, so it will be unset.")
expect(Bundler.settings.without).not_to eq([])
end
end
@@ -468,7 +468,7 @@ describe "setting `with` and `without` options" do
it "does not print a message" do
bundle "config --local with foo"
- # expect(out).not_to include("already set `without foo --global`, so it will be unset.")
+ expect(out).not_to include("already set `without foo` globally, so it will be unset.")
expect(Bundler.settings.without).not_to eq([])
end
end
@@ -477,7 +477,7 @@ describe "setting `with` and `without` options" do
it "prints a message" do
bundle "config --global with foo"
- # expect(out).to include("already set `without foo --global`, so it will be unset.")
+ expect(out).to include("already set `without foo` globally, so it will be unset.")
expect(Bundler.settings.without).to eq([])
end
end