From 9413dba432b11d86b80449ca7b959b32ecb0844c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 28 Jun 2009 19:46:34 +0200 Subject: Added tessts for resources generator. --- .../test/generators/migration_generator_test.rb | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'railties/test/generators/migration_generator_test.rb') diff --git a/railties/test/generators/migration_generator_test.rb b/railties/test/generators/migration_generator_test.rb index 90bc91344f..547ca6a9e3 100644 --- a/railties/test/generators/migration_generator_test.rb +++ b/railties/test/generators/migration_generator_test.rb @@ -20,32 +20,34 @@ class MigrationGeneratorTest < GeneratorsTestCase def test_add_migration_with_attributes @migration = "add_title_body_to_posts" run_generator [@migration, "title:string", "body:text"] - content = assert_migration "db/migrate/#{@migration}.rb" - assert_class_method_for content, :up do |up| - assert_match /add_column :posts, :title, :string/, up - assert_match /add_column :posts, :body, :text/, up - end + assert_migration "db/migrate/#{@migration}.rb" do |content| + assert_class_method content, :up do |up| + assert_match /add_column :posts, :title, :string/, up + assert_match /add_column :posts, :body, :text/, up + end - assert_class_method_for content, :down do |down| - assert_match /remove_column :posts, :title/, down - assert_match /remove_column :posts, :body/, down + assert_class_method content, :down do |down| + assert_match /remove_column :posts, :title/, down + assert_match /remove_column :posts, :body/, down + end end end def test_remove_migration_with_attributes @migration = "remove_title_body_from_posts" run_generator [@migration, "title:string", "body:text"] - content = assert_migration "db/migrate/#{@migration}.rb" - assert_class_method_for content, :up do |up| - assert_match /remove_column :posts, :title/, up - assert_match /remove_column :posts, :body/, up - end + assert_migration "db/migrate/#{@migration}.rb" do |content| + assert_class_method content, :up do |up| + assert_match /remove_column :posts, :title/, up + assert_match /remove_column :posts, :body/, up + end - assert_class_method_for content, :down do |down| - assert_match /add_column :posts, :title, :string/, down - assert_match /add_column :posts, :body, :text/, down + assert_class_method content, :down do |down| + assert_match /add_column :posts, :title, :string/, down + assert_match /add_column :posts, :body, :text/, down + end end end -- cgit v1.2.3