diff options
author | Jakub Kuźma <qoobaa@gmail.com> | 2011-11-26 19:57:51 +0100 |
---|---|---|
committer | Jakub Kuźma <qoobaa@gmail.com> | 2011-11-26 19:57:51 +0100 |
commit | 4e5eaae1faebe5e889a50a3c3cfade397f39863c (patch) | |
tree | 828d6fac16efcae4ba5d4ad44a529f64fea827a1 /railties/test/generators | |
parent | 89d6db05d74ba8cb1d99aaa2166f02dd67a34a36 (diff) | |
download | rails-4e5eaae1faebe5e889a50a3c3cfade397f39863c.tar.gz rails-4e5eaae1faebe5e889a50a3c3cfade397f39863c.tar.bz2 rails-4e5eaae1faebe5e889a50a3c3cfade397f39863c.zip |
added tests, replaced classify with constantize - using classify here cuts the last 's' in ORM name
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/orm_test.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/railties/test/generators/orm_test.rb b/railties/test/generators/orm_test.rb new file mode 100644 index 0000000000..9dd3d3e0ec --- /dev/null +++ b/railties/test/generators/orm_test.rb @@ -0,0 +1,38 @@ +require "generators/generators_test_helper" +require "rails/generators/rails/scaffold_controller/scaffold_controller_generator" + +# Mock out two ORMs +module ORMWithGenerators + module Generators + class ActiveModel + def initialize(name) + end + end + end +end + +module ORMWithoutGenerators + # No generators +end + +class OrmTest < Rails::Generators::TestCase + include GeneratorsTestHelper + tests Rails::Generators::ScaffoldControllerGenerator + + def test_orm_class_returns_custom_generator_if_supported_custom_orm_set + g = generator ["Foo"], :orm => "ORMWithGenerators" + assert_equal ORMWithGenerators::Generators::ActiveModel, g.send(:orm_class) + end + + def test_orm_class_returns_rails_generator_if_unsupported_custom_orm_set + g = generator ["Foo"], :orm => "ORMWithoutGenerators" + assert_equal Rails::Generators::ActiveModel, g.send(:orm_class) + end + + def test_orm_instance_returns_orm_class_instance_with_name + g = generator ["Foo"] + orm_instance = g.send(:orm_instance) + assert g.send(:orm_class) === orm_instance + assert_equal "foo", orm_instance.name + end +end |