aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-03-19 18:11:37 +0100
committerJosé Valim <jose.valim@gmail.com>2010-03-19 18:12:54 +0100
commit562154fcbc8f36f94c986a3253c73ae88e2c1146 (patch)
tree69f03eef669c16786dc71385decacfa6e856a06c /railties/test/generators
parent541194f641c960efe739b16f76999f47742d12ba (diff)
downloadrails-562154fcbc8f36f94c986a3253c73ae88e2c1146.tar.gz
rails-562154fcbc8f36f94c986a3253c73ae88e2c1146.tar.bz2
rails-562154fcbc8f36f94c986a3253c73ae88e2c1146.zip
Controller generator now creates routes as well [#4233 state:resolved]
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/controller_generator_test.rb9
-rw-r--r--railties/test/generators/generators_test_helper.rb7
-rw-r--r--railties/test/generators/resource_generator_test.rb10
-rw-r--r--railties/test/generators/scaffold_generator_test.rb10
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