提交 ccc9f0b7 编写于 作者: J José Valim

Ensure application names are not singularized.

上级 8fe66f1a
...@@ -194,7 +194,7 @@ def app_name ...@@ -194,7 +194,7 @@ def app_name
end end
def app_const_base def app_const_base
@app_const_base ||= app_name.gsub(/\W/, '_').squeeze('_').classify @app_const_base ||= app_name.gsub(/\W/, '_').squeeze('_').camelize
end end
def app_const def app_const
......
...@@ -55,16 +55,21 @@ def test_invalid_database_option_raises_an_error ...@@ -55,16 +55,21 @@ def test_invalid_database_option_raises_an_error
end end
def test_invalid_application_name_raises_an_error 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 assert_equal "Invalid application name 43-things. Please give a name which does not start with numbers.\n", content
end end
def test_invalid_application_name_is_fixed 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/environment.rb", /Things43::Application\.initialize!/
assert_file "things-43/config/application.rb", /^module Things43$/ assert_file "things-43/config/application.rb", /^module Things43$/
end 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 def test_config_database_is_added_by_default
run_generator run_generator
assert_file "config/database.yml", /sqlite3/ assert_file "config/database.yml", /sqlite3/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册