From 1d510a952d7345ffbe4565f417aeb1322dd1a8ac Mon Sep 17 00:00:00 2001 From: gemmaro Date: Mon, 25 Nov 2024 22:40:23 +0900 Subject: [PATCH] [rubygems/rubygems] Fix test task name on generated readme when using test-unit * bundler/lib/bundler/templates/newgem/README.md.tt (Development): Use the test_task value to get the correct test task name ("test", not "test-unit"). * bundler/spec/commands/newgem_spec.rb (README.md): Add tests for test task names for each test frameworks. https://github.com/rubygems/rubygems/commit/2a24708a63 --- lib/bundler/templates/newgem/README.md.tt | 2 +- spec/bundler/commands/newgem_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/bundler/templates/newgem/README.md.tt b/lib/bundler/templates/newgem/README.md.tt index f9c97d5c7e..0ec6a12fa7 100644 --- a/lib/bundler/templates/newgem/README.md.tt +++ b/lib/bundler/templates/newgem/README.md.tt @@ -26,7 +26,7 @@ TODO: Write usage instructions here ## Development -After checking out the repo, run `bin/setup` to install dependencies.<% if config[:test] %> Then, run `rake <%= config[:test].sub('mini', '').sub('rspec', 'spec') %>` to run the tests.<% end %> You can also run `bin/console` for an interactive prompt that will allow you to experiment.<% if config[:bin] %> Run `bundle exec <%= config[:name] %>` to use the gem in this directory, ignoring other installed copies of this gem.<% end %> +After checking out the repo, run `bin/setup` to install dependencies.<% if config[:test] %> Then, run `rake <%= config[:test_task] %>` to run the tests.<% end %> You can also run `bin/console` for an interactive prompt that will allow you to experiment.<% if config[:bin] %> Run `bundle exec <%= config[:name] %>` to use the gem in this directory, ignoring other installed copies of this gem.<% end %> To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). <% if config[:git] -%> diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index 9a5bc9c24f..2389eda521 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -428,6 +428,22 @@ RSpec.describe "bundle gem" do expect(bundled_app("#{gem_name}/README.md").read).not_to include("github.com/bundleuser") end end + + describe "test task name on readme" do + shared_examples_for "test task name on readme" do |framework, task_name| + before do + bundle "gem #{gem_name} --test=#{framework}" + end + + it "renders with correct name" do + expect(bundled_app("#{gem_name}/README.md").read).to include("Then, run `rake #{task_name}` to run the tests.") + end + end + + it_behaves_like "test task name on readme", "test-unit", "test" + it_behaves_like "test task name on readme", "minitest", "test" + it_behaves_like "test task name on readme", "rspec", "spec" + end end it "creates a new git repository" do