summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFrank Lam <ryzingsun11@yahoo.com>2020-04-24 16:00:59 +0800
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-06-05 07:32:42 +0900
commitf75bd9bb8bf1764de613ab1b601d21c46b1d4681 (patch)
tree31db6e7252257250600af76b93991d008d31a65d /lib
parent603edfcaa0aa6ea6660d045194769046d24a59aa (diff)
[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
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3184
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/gem.rb8
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 3d5194d61f..ec3044ee5b 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -573,7 +573,7 @@ module Bundler
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 3fd67d9a88..7fe76adf4c 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -213,10 +213,12 @@ module Bundler
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