[前][次][番号順一覧][スレッド一覧]

ruby-changes:61505

From: Frank <ko1@a...>
Date: Fri, 5 Jun 2020 07:33:35 +0900 (JST)
Subject: [ruby-changes:61505] f75bd9bb8b (master): [rubygems/rubygems] Fix bundle gem ignoring global gem.test config

https://git.ruby-lang.org/ruby.git/commit/?id=f75bd9bb8b

From f75bd9bb8bf1764de613ab1b601d21c46b1d4681 Mon Sep 17 00:00:00 2001
From: Frank Lam <ryzingsun11@y...>
Date: Fri, 24 Apr 2020 16:00:59 +0800
Subject: [rubygems/rubygems] Fix bundle gem ignoring global gem.test config

* bundle gem previously ignored gem.test when passed empty -t flag,
defaulting to RSpec
* bundle gem will now ask user for test framework when passed empty -t
flag and gem.test is set to false, but will not overwrite gem.test
* thor option parsing for String types falls back to human name for nil,
so setting lazy_default to nil won't work
* https://github.com/erikhuda/thor/blob/c5161501e0cfac7a8c5b838a9c6084c275f03c0d/lib/thor/parser/options.rb#L224

Default to Bundler.settings["gem.test"] for empty --test

Add shared examples for test framework to newgem spec

Add examples for empty --test flag to newgem spec

Simplify conditional for prompting test framework

Follow naming conventions for bundler settings

Add more descriptive test framework help text for bundle gem

Update man pages for bundler

https://github.com/rubygems/rubygems/commit/ab0785a09f

diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 3d5194d..ec3044e 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -573,7 +573,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli.rb#L573
     method_option :git, :type => :boolean, :default => true, :desc => "Initialize a git repo inside your library."
     method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config set gem.mit true`."
     method_option :rubocop, :type => :boolean, :desc => "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set gem.rubocop true`."
-    method_option :test, :type => :string, :lazy_default => "rspec", :aliases => "-t", :banner => "rspec",
+    method_option :test, :type => :string, :lazy_default => Bundler.settings["gem.test"] || "", :aliases => "-t", :banner => "Use the specified test framework for your library",
                          :desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set gem.test rspec`."
     def gem(name)
     end
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index 3fd67d9..7fe76ad 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -213,10 +213,12 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L213
     def ask_and_set_test_framework
       test_framework = options[:test] || Bundler.settings["gem.test"]
 
-      if test_framework.nil?
+      if test_framework.to_s.empty?
         Bundler.ui.confirm "Do you want to generate tests with your gem?"
-        result = Bundler.ui.ask "Type 'rspec', 'minitest' or 'test-unit' to generate those test files now and " \
-          "in the future. rspec/minitest/test-unit/(none):"
+        result = Bundler.ui.ask "Type 'rspec', 'minitest' or 'test-unit' to generate those test files now. \n" \
+                                "If Bundler is configured to not generate test files, your choice will only be applied to this instance. \n" \
+                                "Otherwise, future bundle gem calls will use your choice, so -t is not needed if your choice will be the same. \n" \
+                                "This setting can be changed anytime with bundle config gem.test <value>. rspec/minitest/test-unit/(none):"
         if result =~ /rspec|minitest|test-unit/
           test_framework = result
         else
diff --git a/man/bundle-check.1.txt b/man/bundle-check.1.txt
index 8c81ba6..e82dd0e 100644
--- a/man/bundle-check.1.txt
+++ b/man/bundle-check.1.txt
@@ -9,8 +9,8 @@ SYNOPSIS https://github.com/ruby/ruby/blob/trunk/man/bundle-check.1.txt#L9
        bundle check [--dry-run] [--gemfile=FILE] [--path=PATH]
 
 DESCRIPTION
-       check  searches the local machine for each of the gems requested in the
-       Gemfile. If all gems are found, Bundler prints a  success  message  and
+       check searches the local machine for each of the gems requested in  the
+       Gemfile.  If  all  gems are found, Bundler prints a success message and
        exits with a status of 0.
 
        If not, the first missing gem is listed and Bundler exits status 1.
@@ -23,8 +23,8 @@ OPTIONS https://github.com/ruby/ruby/blob/trunk/man/bundle-check.1.txt#L23
               Use     the     specified     gemfile     instead     of     the
               [Gemfile(5)][Gemfile(5)].
 
-       --path Specify a different path than the system  default  ($BUNDLE_PATH
-              or  $GEM_HOME).  Bundler  will  remember  this  value for future
+       --path Specify  a  different path than the system default ($BUNDLE_PATH
+              or $GEM_HOME). Bundler  will  remember  this  value  for  future
               installs on this machine.
 
 
diff --git a/man/bundle-config.1.txt b/man/bundle-config.1.txt
index e6f7e0e..e6add9e 100644
--- a/man/bundle-config.1.txt
+++ b/man/bundle-config.1.txt
@@ -68,29 +68,29 @@ REMEMBERING OPTIONS https://github.com/ruby/ruby/blob/trunk/man/bundle-config.1.txt#L68
        foo or --without production, are remembered between commands and  saved
        to your local application's configuration (normally, ./.bundle/config).
 
-       However,  this will be changed in bundler 3, so it's better not to rely
-       on this behavior. If these options must be remembered, it's  better  to
+       However, this will be changed in bundler 3, so it's better not to  rely
+       on  this  behavior. If these options must be remembered, it's better to
        set them using bundle config (e.g., bundle config set path foo).
 
        The options that can be configured are:
 
-       bin    Creates   a   directory   (defaults  to  ~/bin)  and  place  any
+       bin    Creates  a  directory  (defaults  to  ~/bin)   and   place   any
               executables  from  the  gem  there.  These  executables  run  in
               Bundler's context. If used, you might add this directory to your
-              environment's PATH variable. For  instance,  if  the  rails  gem
+              environment's  PATH  variable.  For  instance,  if the rails gem
               comes with a rails executable, this flag will create a bin/rails
-              executable that ensures that all referred dependencies  will  be
+              executable  that  ensures that all referred dependencies will be
               resolved using the bundled gems.
 
        deployment
-              In  deployment  mode,  Bundler  will  'roll-out'  the bundle for
-              production use. Please check carefully if you want to have  this
+              In deployment mode,  Bundler  will  'roll-out'  the  bundle  for
+              production  use. Please check carefully if you want to have this
               option enabled in development or test environments.
 
-       path   The  location to install the specified gems to. This defaults to
-              Rubygems' setting. Bundler shares this location  with  Rubygems,
-              gem  install  ... will have gem installed there, too. Therefore,
-              gems installed without a --path ...  setting  will  show  up  by
+       path   The location to install the specified gems to. This defaults  to
+              Rubygems'  setting.  Bundler shares this location with Rubygems,
+              gem install ... will have gem installed there,  too.  Therefore,
+              gems  installed  without  a  --path  ... setting will show up by
               calling gem list. Accordingly, gems installed to other locations
               will not get listed.
 
@@ -98,15 +98,15 @@ REMEMBERING OPTIONS https://github.com/ruby/ruby/blob/trunk/man/bundle-config.1.txt#L98
               A space-separated list of groups referencing gems to skip during
               installation.
 
-       with   A  space-separated  list  of  groups referencing gems to include
+       with   A space-separated list of groups  referencing  gems  to  include
               during installation.
 
 BUILD OPTIONS
-       You can use bundle config to give Bundler the flags to pass to the  gem
+       You  can use bundle config to give Bundler the flags to pass to the gem
        installer every time bundler tries to install a particular gem.
 
-       A  very  common  example, the mysql gem, requires Snow Leopard users to
-       pass configuration flags to gem install to specify where  to  find  the
+       A very common example, the mysql gem, requires Snow  Leopard  users  to
+       pass  configuration  flags  to gem install to specify where to find the
        mysql_config executable.
 
 
@@ -115,7 +115,7 @@ BUILD OPTIONS https://github.com/ruby/ruby/blob/trunk/man/bundle-config.1.txt#L115
 
 
 
-       Since  the specific location of that executable can change from machine
+       Since the specific location of that executable can change from  machine
        to machine, you can specify these flags on a per-machine basis.
 
 
@@ -124,44 +124,44 @@ BUILD OPTIONS https://github.com/ruby/ruby/blob/trunk/man/bundle-config.1.txt#L124
 
 
 
-       After running this command, every time bundler  needs  to  install  the
+       After  running  this  command,  every time bundler needs to install the
        mysql gem, it will pass along the flags you specified.
 
 CONFIGURATION KEYS
-       Configuration  keys  in  bundler have two forms: the canonical form and
+       Configuration keys in bundler have two forms: the  canonical  form  and
        the environment variable form.
 
-       For  instance,  passing  the  --without  flag  to   bundle   install(1)
-       bundle-install.1.html  prevents  Bundler from installing certain groups
-       specified  in  the  Gemfile(5).  Bundler   persists   this   value   in
-       app/.bundle/config  so  that  calls to Bundler.setup do not try to find
+       For   instance,   passing  the  --without  flag  t (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]