aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-06-25 11:56:18 +0200
committerJosé Valim <jose.valim@gmail.com>2009-06-25 11:56:18 +0200
commited33c29a4e2a07c2a738ec13775c5cc0d7867b50 (patch)
treebd3c7fde46d7366adc7d87982c509fa5d9c55933 /railties/test/generators
parent4573fd2e06ee9b5a68f84f085f0a10c9ad6f129b (diff)
downloadrails-ed33c29a4e2a07c2a738ec13775c5cc0d7867b50.tar.gz
rails-ed33c29a4e2a07c2a738ec13775c5cc0d7867b50.tar.bz2
rails-ed33c29a4e2a07c2a738ec13775c5cc0d7867b50.zip
Added class collision checks.
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/generators_test_helper.rb6
-rw-r--r--railties/test/generators/metal_generator_test.rb9
-rw-r--r--railties/test/generators/plugin_generator_test.rb15
3 files changed, 18 insertions, 12 deletions
diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb
index 9462fc2214..1fcfdaebb9 100644
--- a/railties/test/generators/generators_test_helper.rb
+++ b/railties/test/generators/generators_test_helper.rb
@@ -12,12 +12,8 @@ class GeneratorsTestCase < Test::Unit::TestCase
end
def setup
- mkdir_p(destination_root)
- rm_rf(destination_root)
- end
-
- def teardown
rm_rf(destination_root)
+ mkdir_p(destination_root)
end
def test_truth
diff --git a/railties/test/generators/metal_generator_test.rb b/railties/test/generators/metal_generator_test.rb
index dfa948d14e..4e73883feb 100644
--- a/railties/test/generators/metal_generator_test.rb
+++ b/railties/test/generators/metal_generator_test.rb
@@ -9,10 +9,15 @@ class MetalGeneratorTest < GeneratorsTestCase
assert_file "app/metal/foo.rb", /class Foo/
end
+ def test_check_class_collision
+ content = capture(:stderr){ run_generator ["object"] }
+ assert_match /The name 'Object' is either already used in your application or reserved/, content
+ end
+
protected
- def run_generator(args=[])
- silence(:stdout) { Rails::Generators::MetalGenerator.start ["foo"].concat(args), :root => destination_root }
+ def run_generator(args=["foo"])
+ silence(:stdout) { Rails::Generators::MetalGenerator.start args, :root => destination_root }
end
end
diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb
index b4aa39ae5f..3f2b27c518 100644
--- a/railties/test/generators/plugin_generator_test.rb
+++ b/railties/test/generators/plugin_generator_test.rb
@@ -15,23 +15,28 @@ class PluginGeneratorTest < GeneratorsTestCase
).each{ |path| assert_file path }
end
+ def test_check_class_collision
+ content = capture(:stderr){ run_generator ["object"] }
+ assert_match /The name 'Object' is either already used in your application or reserved/, content
+ end
+
def test_invokes_default_test_framework
run_generator
assert_file "vendor/plugins/plugin_fu/test/plugin_fu_test.rb"
end
def test_logs_if_the_test_framework_cannot_be_found
- content = run_generator ["--test-framework=unknown"]
+ content = run_generator ["plugin_fu", "--test-framework=unknown"]
assert_match /Could not find and invoke 'unknown:generators:plugin'/, content
end
def test_creates_tasks_if_required
- run_generator ["--with-tasks"]
+ run_generator ["plugin_fu", "--with-tasks"]
assert_file "vendor/plugins/plugin_fu/tasks/plugin_fu_tasks.rake"
end
def test_creates_generator_if_required
- run_generator ["--with-generator"]
+ run_generator ["plugin_fu", "--with-generator"]
assert_file "vendor/plugins/plugin_fu/generators/plugin_fu/templates"
flag = /class PluginFuGenerator < Rails::Generators::NamedBase/
@@ -40,8 +45,8 @@ class PluginGeneratorTest < GeneratorsTestCase
protected
- def run_generator(args=[])
- silence(:stdout) { Rails::Generators::PluginGenerator.start ["plugin_fu"].concat(args), :root => destination_root }
+ def run_generator(args=["plugin_fu"])
+ silence(:stdout) { Rails::Generators::PluginGenerator.start args, :root => destination_root }
end
end