summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-07-30 23:24:37 +0000
committerColby Swandale <me@colby.fyi>2018-10-05 13:48:27 +1000
commite3897b31ad919a779e682df5f1cf0af98f250c11 (patch)
tree4d5403606cb456c6d776906a94a333b031e5ab27
parent9a266ecd55cd6d23552f5178a9daee0bb1eaec43 (diff)
downloadbundler-e3897b31ad919a779e682df5f1cf0af98f250c11.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. (cherry picked from commit 1a10427f9c76ffb29de25fe75d15c950682d01e4)
-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 9c67a80777..c1e5812887 100644
--- a/lib/bundler/injector.rb
+++ b/lib/bundler/injector.rb
@@ -75,7 +75,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 d1f2050aa0..799c8a1b93 100644
--- a/spec/commands/add_spec.rb
+++ b/spec/commands/add_spec.rb
@@ -61,7 +61,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
@@ -82,7 +82,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