ruby-changes:61508
From: Frank <ko1@a...>
Date: Fri, 5 Jun 2020 07:33:36 +0900 (JST)
Subject: [ruby-changes:61508] 154c2717da (master): [rubygems/rubygems] Add user hint specs for bundle gem --test
https://git.ruby-lang.org/ruby.git/commit/?id=154c2717da From 154c2717da6bb59f1b2739777b01cea98b667751 Mon Sep 17 00:00:00 2001 From: Frank Lam <ryzingsun11@y...> Date: Sat, 23 May 2020 01:00:00 +0800 Subject: [rubygems/rubygems] Add user hint specs for bundle gem --test https://github.com/rubygems/rubygems/commit/1d2292a88f diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index 57fc635..2c2ed27 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -181,7 +181,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L181 if options[:test] == Bundler.settings["gem.test"] Bundler.ui.info "Bundler is configured to generate test files for #{Bundler.settings["gem.test"]}, "\ "so -t is not needed if you want to continue using it. " \ - "This setting can be changed anytime with bundle config gem.test." + "This setting can be changed anytime with `bundle config gem.test`." end rescue Errno::EEXIST => e raise GenericSystemCallError.new(e, "There was a conflict while creating the new gem.") @@ -222,7 +222,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L222 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. \n" \ - "#{test_framework_help_info} rspec/minitest/test-unit/(none):" + "#{test_framework_hint} rspec/minitest/test-unit/(none):" if result =~ /rspec|minitest|test-unit/ test_framework = result else @@ -237,12 +237,12 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L237 test_framework end - def test_framework_help_info + def test_framework_hint if Bundler.settings["gem.test"] == false "Your choice will only be applied to this gem." else - "Future bundle gem calls will use your choice. " \ - "This setting can be changed anytime with bundle config gem.test." + "Future `bundle gem` calls will use your choice. " \ + "This setting can be changed anytime with `bundle config gem.test`." end end diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index fcefa4d..4b7a88b 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -623,18 +623,32 @@ RSpec.describe "bundle gem" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/newgem_spec.rb#L623 expect(bundled_app("#{gem_name}/spec/spec_helper.rb")).to exist end + it "hints that --test is not needed" do + hint = "Bundler is configured to generate test files for rspec, "\ + "so -t is not needed if you want to continue using it. " \ + "This setting can be changed anytime with `bundle config gem.test`." + expect(last_command.stdout).to match(hint) + end + it_behaves_like "test framework is present" end context "gem.test setting set to false and --test with no arguments" do before do bundle "config set gem.test false" + bundle! "gem #{gem_name} --test" end it "asks to generate test files" do - result = bundle! "gem #{gem_name} --test" - expect(result).to match("Do you want to generate tests with your gem?") + expect(last_command.stdout).to match("Do you want to generate tests with your gem?") + end + + it "hints that the choice will only be applied to the current gem" do + hint = "Your choice will only be applied to this gem." + expect(last_command.stdout).to match(hint) end + + it_behaves_like "test framework is absent" end context "gem.test setting not set and --test with no arguments" do @@ -642,6 +656,12 @@ RSpec.describe "bundle gem" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/newgem_spec.rb#L656 bundle! "gem #{gem_name} --test" end + it "hints that the choice will be applied to future bundle gem calls" do + hint = "Future `bundle gem` calls will use your choice. " \ + "This setting can be changed anytime with `bundle config gem.test`." + expect(last_command.stdout).to match(hint) + end + it_behaves_like "test framework is absent" end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/