зеркало из https://github.com/github/ruby.git
[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
This commit is contained in:
Родитель
5c4734d1ef
Коммит
4e955b2e37
|
@ -106,7 +106,7 @@ module Bundler
|
|||
when "minitest"
|
||||
templates.merge!(
|
||||
"test/minitest/test_helper.rb.tt" => "test/test_helper.rb",
|
||||
"test/minitest/test_newgem.rb.tt" => "test/test_#{namespaced_path}.rb"
|
||||
"test/minitest/test_newgem.rb.tt" => "test/test_#{underscored_name}.rb"
|
||||
)
|
||||
config[:test_task] = :test
|
||||
when "test-unit"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require "test_helper"
|
||||
|
||||
class Test<%= config[:constant_name] %> < Minitest::Test
|
||||
class Test<%= config[:constant_name].gsub('::', '') %> < Minitest::Test
|
||||
def test_that_it_has_a_version_number
|
||||
refute_nil ::<%= config[:constant_name] %>::VERSION
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче