summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-07-30 23:24:37 +0000
committerThe Bundler Bot <bot@bundler.io>2018-07-30 23:24:37 +0000
commit1a10427f9c76ffb29de25fe75d15c950682d01e4 (patch)
treed8fca0e3e1149169bfbde80d814be7347d16d6c4
parent42c4609e01c0869f5341f658d2a345a8969fa3e2 (diff)
parent38e761e4babb6ef69872337cfc3d2da20e64215b (diff)
downloadbundler-1a10427f9c76ffb29de25fe75d15c950682d01e4.tar.gz
Auto merge of #6627 - agrim123:agr-fix-add-groups, r=deivid-rodriguez
Fix singular groups on injecting gem ### What was the end-user problem that led to this PR? The problem was that on adding a gem to a group via ```bash bundle add rack --group=dev ``` It gets added as ```ruby gem "rack", :group => [:dev] ``` It should rather be ```ruby gem "rack", :group => :dev ``` ### What was your diagnosis of the problem? My diagnosis was to not add single groups in the array. ### What is your fix for the problem, implemented in this PR? My fix was to pick the element from the array of groups and append using ```ruby ":group => :#{d.groups.first}" ``` ### Why did you choose this fix out of the possible options? I chose this fix because it seemed to most appropriate.
-rw-r--r--lib/bundler/injector.rb2
-rw-r--r--spec/commands/add_spec.rb4
-rw-r--r--spec/commands/inject_spec.rb2
3 files changed, 4 insertions, 4 deletions
diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb
index 0eae0c6ece..1bb29f0b36 100644
--- a/lib/bundler/injector.rb
+++ b/lib/bundler/injector.rb
@@ -107,7 +107,7 @@ module Bundler
end
if d.groups != Array(:default)
- group = d.groups.size == 1 ? ", :group => #{d.groups.inspect}" : ", :groups => #{d.groups.inspect}"
+ group = d.groups.size == 1 ? ", :group => #{d.groups.first.inspect}" : ", :groups => #{d.groups.inspect}"
end
source = ", :source => \"#{d.source}\"" unless d.source.nil?
diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb
index 2e9ef6b923..9f11adbcf8 100644
--- a/spec/commands/add_spec.rb
+++ b/spec/commands/add_spec.rb
@@ -69,7 +69,7 @@ RSpec.describe "bundle add" do
describe "with --group" do
it "adds dependency for the specified group" do
bundle "add 'foo' --group='development'"
- expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :group => \[:development\]/)
+ expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :group => :development/)
expect(the_bundle).to include_gems "foo 2.0"
end
@@ -100,7 +100,7 @@ RSpec.describe "bundle add" do
it "using combination of short form options works like long form" do
bundle "add 'foo' -s='file://#{gem_repo2}' -g='development' -v='~>1.0'"
- expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 1.0", :group => [:development], :source => "file://#{gem_repo2}")
+ expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 1.0", :group => :development, :source => "file://#{gem_repo2}")
expect(the_bundle).to include_gems "foo 1.1"
end
diff --git a/spec/commands/inject_spec.rb b/spec/commands/inject_spec.rb
index 6c1994b59d..b7ffc89a34 100644
--- a/spec/commands/inject_spec.rb
+++ b/spec/commands/inject_spec.rb
@@ -64,7 +64,7 @@ Usage: "bundle inject GEM VERSION"
it "add gem with group option in gemfile" do
bundle "inject 'rack-obama' '>0' --group=development"
gemfile = bundled_app("Gemfile").read
- str = "gem \"rack-obama\", \"> 0\", :group => [:development]"
+ str = "gem \"rack-obama\", \"> 0\", :group => :development"
expect(gemfile).to include str
end