mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Update generated minitest file style
foo => test/test_foo.rb foo-bar => test/foo/test_bar.rb foo_bar => test/test_foo_bar.rb https://github.com/rubygems/rubygems/commit/c795e5d40d
This commit is contained in:
parent
4e955b2e37
commit
4451313252
2 changed files with 19 additions and 9 deletions
|
@ -104,9 +104,17 @@ module Bundler
|
|||
)
|
||||
config[:test_task] = :spec
|
||||
when "minitest"
|
||||
# Generate path for minitest target file (FileList["test/**/test_*.rb"])
|
||||
# foo => test/test_foo.rb
|
||||
# foo-bar => test/foo/test_bar.rb
|
||||
# foo_bar => test/test_foo_bar.rb
|
||||
paths = namespaced_path.rpartition("/")
|
||||
paths[2] = "test_#{paths[2]}"
|
||||
minitest_namespaced_path = paths.join("")
|
||||
|
||||
templates.merge!(
|
||||
"test/minitest/test_helper.rb.tt" => "test/test_helper.rb",
|
||||
"test/minitest/test_newgem.rb.tt" => "test/test_#{underscored_name}.rb"
|
||||
"test/minitest/test_newgem.rb.tt" => "test/#{minitest_namespaced_path}.rb"
|
||||
)
|
||||
config[:test_task] = :test
|
||||
when "test-unit"
|
||||
|
|
|
@ -28,6 +28,8 @@ RSpec.describe "bundle gem" do
|
|||
|
||||
let(:require_path) { "mygem" }
|
||||
|
||||
let(:minitest_test_file_path) { "test/test_mygem.rb" }
|
||||
|
||||
before do
|
||||
sys_exec("git config --global user.name 'Bundler User'")
|
||||
sys_exec("git config --global user.email user@example.com")
|
||||
|
@ -696,22 +698,18 @@ 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_#{underscored_require_path}.rb")).to exist
|
||||
expect(bundled_app("#{gem_name}/#{minitest_test_file_path}")).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
|
||||
|
@ -726,7 +724,7 @@ RSpec.describe "bundle gem" do
|
|||
end
|
||||
|
||||
it "builds spec skeleton" do
|
||||
expect(bundled_app("#{gem_name}/test/test_#{underscored_require_path}.rb")).to exist
|
||||
expect(bundled_app("#{gem_name}/#{minitest_test_file_path}")).to exist
|
||||
expect(bundled_app("#{gem_name}/test/test_helper.rb")).to exist
|
||||
end
|
||||
|
||||
|
@ -735,11 +733,11 @@ RSpec.describe "bundle gem" do
|
|||
end
|
||||
|
||||
it "requires 'test_helper'" do
|
||||
expect(bundled_app("#{gem_name}/test/test_#{underscored_require_path}.rb").read).to include(%(require "test_helper"))
|
||||
expect(bundled_app("#{gem_name}/#{minitest_test_file_path}").read).to include(%(require "test_helper"))
|
||||
end
|
||||
|
||||
it "creates a default test which fails" do
|
||||
expect(bundled_app("#{gem_name}/test/test_#{underscored_require_path}.rb").read).to include("assert false")
|
||||
expect(bundled_app("#{gem_name}/#{minitest_test_file_path}").read).to include("assert false")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1304,6 +1302,8 @@ RSpec.describe "bundle gem" do
|
|||
|
||||
let(:require_relative_path) { "test_gem" }
|
||||
|
||||
let(:minitest_test_file_path) { "test/test_test_gem.rb" }
|
||||
|
||||
let(:flags) { nil }
|
||||
|
||||
it "does not nest constants" do
|
||||
|
@ -1359,6 +1359,8 @@ RSpec.describe "bundle gem" do
|
|||
|
||||
let(:require_relative_path) { "gem" }
|
||||
|
||||
let(:minitest_test_file_path) { "test/test/test_gem.rb" }
|
||||
|
||||
it "nests constants so they work" do
|
||||
bundle "gem #{gem_name}"
|
||||
expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb").read).to match(/module Test\n module Gem/)
|
||||
|
|
Loading…
Add table
Reference in a new issue