diff options
author | Yusuke Nakamura <yusuke1994525@gmail.com> | 2022-01-10 21:51:51 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-01-20 01:04:52 +0900 |
commit | 4e955b2e379a550cebd27e5d66fd5bcd98c70cf7 (patch) | |
tree | b71b8a0eca3e317b1ce1faae2c0deef42e5bc990 /spec/bundler | |
parent | 5c4734d1eff9322f9f21d9c21577978ab6e0d044 (diff) | |
download | ruby-4e955b2e379a550cebd27e5d66fd5bcd98c70cf7.tar.gz |
[rubygems/rubygems] Create minitest file to underscored path in "bundle gem" command
...with dashed gem name
In "bundle gem" command with dashed name gem (e.g. foo-bar) generates
`test/test_foo/bar.rb`, but this file contains undefined class `TestFoo`
and moreover, does not include in "bundle exec rake test" target.
Therefore, intentially the first test after gem created is fail, but in
case of gem name contains dash character is not.
The change doings...
(when "bundle gem foo-bar" called)
* create `test/test_foo_bar.rb`
* define `TestFooBar` class in `test/test_foo_bar.rb`
https://github.com/rubygems/rubygems/commit/5d9a69fc0f
Diffstat (limited to 'spec/bundler')
-rw-r--r-- | spec/bundler/commands/newgem_spec.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index ddefe0ba25..45bd3d5d4e 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -696,18 +696,22 @@ RSpec.describe "bundle gem" do end context "gem.test setting set to rspec and --test is set to minitest" do + let(:underscored_require_path) { require_path.tr("/", "_") } + before do bundle "config set gem.test rspec" bundle "gem #{gem_name} --test=minitest" end it "builds spec skeleton" do - expect(bundled_app("#{gem_name}/test/test_#{require_path}.rb")).to exist + expect(bundled_app("#{gem_name}/test/test_#{underscored_require_path}.rb")).to exist expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist end end context "--test parameter set to minitest" do + let(:underscored_require_path) { require_path.tr("/", "_") } + before do bundle "gem #{gem_name} --test=minitest" end @@ -722,7 +726,7 @@ RSpec.describe "bundle gem" do end it "builds spec skeleton" do - expect(bundled_app("#{gem_name}/test/test_#{require_path}.rb")).to exist + expect(bundled_app("#{gem_name}/test/test_#{underscored_require_path}.rb")).to exist expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist end @@ -731,11 +735,11 @@ RSpec.describe "bundle gem" do end it "requires 'test_helper'" do - expect(bundled_app("#{gem_name}/test/test_#{require_path}.rb").read).to include(%(require "test_helper")) + expect(bundled_app("#{gem_name}/test/test_#{underscored_require_path}.rb").read).to include(%(require "test_helper")) end it "creates a default test which fails" do - expect(bundled_app("#{gem_name}/test/test_#{require_path}.rb").read).to include("assert false") + expect(bundled_app("#{gem_name}/test/test_#{underscored_require_path}.rb").read).to include("assert false") end end |