mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ensure application names are not singularized.
This commit is contained in:
parent
8fe66f1af0
commit
ccc9f0b7de
2 changed files with 8 additions and 3 deletions
|
@ -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/
|
||||
|
|
Loading…
Reference in a new issue