diff options
author | shekharrajak <shekharstudy@ymail.com> | 2017-03-24 11:56:58 +0530 |
---|---|---|
committer | shekharrajak <shekharstudy@ymail.com> | 2017-03-24 11:56:58 +0530 |
commit | cfe4eccfc33a8f6372a7197ffae95c15e023df95 (patch) | |
tree | 8b495e330d8c327fc8fd0b5b2319bc88cad63697 | |
parent | d73d78cb7754b77d3c196d6abb25146b8021af70 (diff) | |
download | bundler-cfe4eccfc33a8f6372a7197ffae95c15e023df95.tar.gz |
multiple groups testcase added and confirmation msg added
-rw-r--r-- | lib/bundler/cli/inject.rb | 10 | ||||
-rw-r--r-- | spec/commands/inject_spec.rb | 7 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/bundler/cli/inject.rb b/lib/bundler/cli/inject.rb index c398038d49..b17292643f 100644 --- a/lib/bundler/cli/inject.rb +++ b/lib/bundler/cli/inject.rb @@ -6,7 +6,7 @@ module Bundler @options = options @name = name @version = version || last_version_number - @group = options[:group] + @group = options[:group].split(",") unless options[:group].nil? @source = options[:source] @gems = [] end @@ -31,7 +31,13 @@ module Bundler if added.any? Bundler.ui.confirm "Added to Gemfile:" - Bundler.ui.confirm added.map {|g| " #{g}, group => #{g.groups.inspect}, :source => '#{g.source.dump}'" }.join("\n") + Bundler.ui.confirm(added.map do |d| + name = "'#{d.name}'" + requirement = ", '#{d.requirement}'" + group = ", :group => #{d.groups.inspect}" if d.groups != Array(:default) + source = ", :source => '#{d.source}'" unless d.source.nil? + %(gem #{name}#{requirement}#{group}#{source}) + end.join("\n")) else Bundler.ui.confirm "All gems were already present in the Gemfile" end diff --git a/spec/commands/inject_spec.rb b/spec/commands/inject_spec.rb index 4fe505d28c..fb7b68e31d 100644 --- a/spec/commands/inject_spec.rb +++ b/spec/commands/inject_spec.rb @@ -68,6 +68,13 @@ Usage: "bundle inject GEM VERSION" str = "gem 'rack-obama', '> 0', :group => [:development]" expect(gemfile).to include str end + + it "add gem with multiple group in gemfile" do + bundle "inject 'rack-obama' '>0' --group=development,test" + gemfile = bundled_app("Gemfile").read + str = "gem 'rack-obama', '> 0', :group => [:development, :test]" + expect(gemfile).to include str + end end context "when frozen" do |