diff options
Diffstat (limited to 'railties/test')
4 files changed, 16 insertions, 20 deletions
diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb index 79a4e5bf17..14773373af 100644 --- a/railties/test/generators/controller_generator_test.rb +++ b/railties/test/generators/controller_generator_test.rb @@ -5,6 +5,8 @@ class ControllerGeneratorTest < Rails::Generators::TestCase include GeneratorsTestHelper arguments %w(Account foo bar) + setup :copy_routes + def test_help_does_not_show_invoked_generators_options_if_they_already_exist content = run_generator ["--help"] assert_no_match /Helper options\:/, content @@ -23,8 +25,6 @@ class ControllerGeneratorTest < Rails::Generators::TestCase Object.send :remove_const, :ObjectController end - # No need to spec content since it's already spec'ed on helper generator. - # def test_invokes_helper run_generator assert_file "app/helpers/account_helper.rb" @@ -53,6 +53,11 @@ class ControllerGeneratorTest < Rails::Generators::TestCase assert_file "app/views/account/bar.html.erb", /app\/views\/account\/bar/ end + def test_add_routes + run_generator + assert_file "config/routes.rb", /get "\/account\/foo" => "account#foo"/, /get "\/account\/bar" => "account#bar"/ + end + def test_invokes_default_template_engine_even_with_no_action run_generator ["account"] assert_file "app/views/account" diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index 32be99b144..9e56b3732f 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -26,4 +26,11 @@ module GeneratorsTestHelper end end end + + def copy_routes + routes = File.expand_path("../../../lib/generators/rails/app/templates/config/routes.rb", __FILE__) + destination = File.join(destination_root, "config") + FileUtils.mkdir_p(destination) + FileUtils.cp File.expand_path(routes), destination + end end
\ No newline at end of file diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb index 959934bd71..5f0dc0c594 100644 --- a/railties/test/generators/resource_generator_test.rb +++ b/railties/test/generators/resource_generator_test.rb @@ -5,15 +5,7 @@ class ResourceGeneratorTest < Rails::Generators::TestCase include GeneratorsTestHelper arguments %w(account) - def setup - super - routes = Rails::Generators::ResourceGenerator.source_root - routes = File.join(routes, "..", "..", "app", "templates", "config", "routes.rb") - destination = File.join(destination_root, "config") - - FileUtils.mkdir_p(destination) - FileUtils.cp File.expand_path(routes), destination - end + setup :copy_routes def test_help_with_inherited_options content = run_generator ["--help"] diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index a7e9c8a231..3ac6c6ad17 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -5,15 +5,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase include GeneratorsTestHelper arguments %w(product_line title:string price:integer) - def setup - super - routes = Rails::Generators::ResourceGenerator.source_root - routes = File.join(routes, "..", "..", "app", "templates", "config", "routes.rb") - destination = File.join(destination_root, "config") - - FileUtils.mkdir_p(destination) - FileUtils.cp File.expand_path(routes), destination - end + setup :copy_routes def test_scaffold_on_invoke run_generator |