diff options
author | José Valim <jose.valim@gmail.com> | 2009-06-26 11:57:40 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-06-26 11:59:14 +0200 |
commit | e2346244a25ea9365ce0c93ca355c710b6712304 (patch) | |
tree | 053cf9f20741971ee71727626da9ff08feaf2d6d /railties/test/generators | |
parent | d40bd851190dd734a09965979c8ade285e51d52c (diff) | |
download | rails-e2346244a25ea9365ce0c93ca355c710b6712304.tar.gz rails-e2346244a25ea9365ce0c93ca355c710b6712304.tar.bz2 rails-e2346244a25ea9365ce0c93ca355c710b6712304.zip |
Added Controller Generators.
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/controller_generator_test.rb | 62 | ||||
-rw-r--r-- | railties/test/generators/mailer_generator_test.rb | 4 |
2 files changed, 64 insertions, 2 deletions
diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb new file mode 100644 index 0000000000..88b54a54ed --- /dev/null +++ b/railties/test/generators/controller_generator_test.rb @@ -0,0 +1,62 @@ +require 'abstract_unit' +require 'generators/generators_test_helper' +require 'generators/erb/controller/controller_generator' +require 'generators/rails/controller/controller_generator' +require 'generators/rails/helper/helper_generator' +require 'generators/test_unit/controller/controller_generator' +require 'generators/test_unit/helper/helper_generator' + +ObjectController = Class.new + +class ControllerGeneratorTest < GeneratorsTestCase + + def test_controller_skeleton_is_created + run_generator + assert_file "app/controllers/account_controller.rb", /class AccountController < ApplicationController/ + end + + def test_check_class_collision + content = capture(:stderr){ run_generator ["object"] } + assert_match /The name 'ObjectController' is either already used in your application or reserved/, content + end + + def test_invokes_helpers + run_generator + assert_file "app/helpers/account_helper.rb" + assert_file "test/unit/helpers/account_helper_test.rb" + end + + def test_invokes_default_test_framework + run_generator + assert_file "test/functional/account_controller_test.rb" + end + + def test_invokes_default_template_engine + run_generator + assert_file "app/views/account/foo.html.erb", /app\/views\/account\/foo/ + assert_file "app/views/account/bar.html.erb", /app\/views\/account\/bar/ + end + + def test_invokes_default_template_engine_even_with_no_action + run_generator ["account"] + assert_file "app/views/account" + end + + def test_template_engine_with_class_path + run_generator ["admin/account"] + assert_file "app/views/admin/account" + end + + def test_actions_are_turned_into_methods + run_generator + assert_file "app/controllers/account_controller.rb", /def foo/ + assert_file "app/controllers/account_controller.rb", /def bar/ + end + + protected + + def run_generator(args=["Account", "foo", "bar"]) + silence(:stdout) { Rails::Generators::ControllerGenerator.start args, :root => destination_root } + end + +end diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb index d702379822..710847587d 100644 --- a/railties/test/generators/mailer_generator_test.rb +++ b/railties/test/generators/mailer_generator_test.rb @@ -25,8 +25,8 @@ class MailerGeneratorTest < GeneratorsTestCase def test_invokes_default_template_engine run_generator - assert_file "app/views/notifier/foo.erb" - assert_file "app/views/notifier/bar.erb" + assert_file "app/views/notifier/foo.erb", /app\/views\/notifier\/foo/ + assert_file "app/views/notifier/bar.erb", /app\/views\/notifier\/bar/ end def test_invokes_default_template_engine_even_with_no_action |