mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Change generated namespaced test class name in minitest
* `foo` => `TestFoo`
* `foo_bar` => `TestFooBar`
* `foo-bar` => `Foo::TestBar`
353cdd61c3
This commit is contained in:
parent
26e0450ba9
commit
7353f950c3
3 changed files with 4 additions and 2 deletions
|
@ -38,6 +38,7 @@ module Bundler
|
||||||
namespaced_path = name.tr("-", "/")
|
namespaced_path = name.tr("-", "/")
|
||||||
constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
|
constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
|
||||||
constant_array = constant_name.split("::")
|
constant_array = constant_name.split("::")
|
||||||
|
minitest_constant_name = constant_array.clone.tap {|a| a[-1] = "Test#{a[-1]}" }.join("::") # Foo::Bar => Foo::TestBar
|
||||||
|
|
||||||
use_git = Bundler.git_present? && options[:git]
|
use_git = Bundler.git_present? && options[:git]
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ module Bundler
|
||||||
:git => use_git,
|
:git => use_git,
|
||||||
:github_username => github_username.empty? ? "[USERNAME]" : github_username,
|
:github_username => github_username.empty? ? "[USERNAME]" : github_username,
|
||||||
:required_ruby_version => required_ruby_version,
|
:required_ruby_version => required_ruby_version,
|
||||||
|
:minitest_constant_name => minitest_constant_name,
|
||||||
}
|
}
|
||||||
ensure_safe_gem_name(name, constant_array)
|
ensure_safe_gem_name(name, constant_array)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class Test<%= config[:constant_name].gsub('::', '') %> < Minitest::Test
|
class <%= config[:minitest_constant_name] %> < Minitest::Test
|
||||||
def test_that_it_has_a_version_number
|
def test_that_it_has_a_version_number
|
||||||
refute_nil ::<%= config[:constant_name] %>::VERSION
|
refute_nil ::<%= config[:constant_name] %>::VERSION
|
||||||
end
|
end
|
||||||
|
|
|
@ -1369,7 +1369,7 @@ RSpec.describe "bundle gem" do
|
||||||
|
|
||||||
let(:minitest_test_file_path) { "test/test/test_gem.rb" }
|
let(:minitest_test_file_path) { "test/test/test_gem.rb" }
|
||||||
|
|
||||||
let(:minitest_test_class_name) { "class TestTestGem < Minitest::Test" }
|
let(:minitest_test_class_name) { "class Test::TestGem < Minitest::Test" }
|
||||||
|
|
||||||
it "nests constants so they work" do
|
it "nests constants so they work" do
|
||||||
bundle "gem #{gem_name}"
|
bundle "gem #{gem_name}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue