mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Ensure application names are not singularized.
This commit is contained in:
@@ -194,7 +194,7 @@ module Rails::Generators
|
||||
end
|
||||
|
||||
def app_const_base
|
||||
@app_const_base ||= app_name.gsub(/\W/, '_').squeeze('_').classify
|
||||
@app_const_base ||= app_name.gsub(/\W/, '_').squeeze('_').camelize
|
||||
end
|
||||
|
||||
def app_const
|
||||
|
||||
@@ -55,16 +55,21 @@ class AppGeneratorTest < GeneratorsTestCase
|
||||
end
|
||||
|
||||
def test_invalid_application_name_raises_an_error
|
||||
content = capture(:stderr){ Rails::Generators::AppGenerator.start [File.join(destination_root, "43-things")] }
|
||||
content = capture(:stderr){ run_generator [File.join(destination_root, "43-things")] }
|
||||
assert_equal "Invalid application name 43-things. Please give a name which does not start with numbers.\n", content
|
||||
end
|
||||
|
||||
def test_invalid_application_name_is_fixed
|
||||
silence(:stdout){ Rails::Generators::AppGenerator.start [File.join(destination_root, "things-43")] }
|
||||
run_generator [File.join(destination_root, "things-43")]
|
||||
assert_file "things-43/config/environment.rb", /Things43::Application\.initialize!/
|
||||
assert_file "things-43/config/application.rb", /^module Things43$/
|
||||
end
|
||||
|
||||
def test_application_names_are_not_singularized
|
||||
run_generator [File.join(destination_root, "hats")]
|
||||
assert_file "hats/config/environment.rb", /Hats::Application\.initialize!/
|
||||
end
|
||||
|
||||
def test_config_database_is_added_by_default
|
||||
run_generator
|
||||
assert_file "config/database.yml", /sqlite3/
|
||||
|
||||
Reference in New Issue
Block a user