aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/generators_test.rb')
-rw-r--r--railties/test/generators_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb
index 60c81a813f..f37b684f73 100644
--- a/railties/test/generators_test.rb
+++ b/railties/test/generators_test.rb
@@ -16,6 +16,7 @@ class GeneratorsTest < Rails::Generators::TestCase
end
def test_simple_invoke
+ assert File.exists?(File.join(@path, 'generators', 'model_generator.rb'))
TestUnit::Generators::ModelGenerator.expects(:start).with(["Account"], {})
Rails::Generators.invoke("test_unit:model", ["Account"])
end
@@ -30,6 +31,13 @@ class GeneratorsTest < Rails::Generators::TestCase
assert_match /Description:/, output
end
+ def test_should_give_higher_preference_to_rails_generators
+ assert File.exists?(File.join(@path, 'generators', 'model_generator.rb'))
+ Rails::Generators::ModelGenerator.expects(:start).with(["Account"], {})
+ warnings = capture(:stderr){ Rails::Generators.invoke :model, ["Account"] }
+ assert warnings.empty?
+ end
+
def test_invoke_with_default_values
Rails::Generators::ModelGenerator.expects(:start).with(["Account"], {})
Rails::Generators.invoke :model, ["Account"]
@@ -148,6 +156,13 @@ class GeneratorsTest < Rails::Generators::TestCase
Rails::Generators.subclasses.delete(klass)
end
+ def test_load_generators_from_railties
+ Rails::Generators::ModelGenerator.expects(:start).with(["Account"], {})
+ Rails::Generators.send(:remove_instance_variable, :@generators_from_railties)
+ Rails.application.expects(:load_generators)
+ Rails::Generators.invoke("model", ["Account"])
+ end
+
def test_rails_root_templates
template = File.join(Rails.root, "lib", "templates", "active_record", "model", "model.rb")