diff options
Diffstat (limited to 'railties/test/generators')
-rw-r--r-- | railties/test/generators/model_generator_test.rb | 22 | ||||
-rw-r--r-- | railties/test/generators/resource_generator_test.rb | 13 |
2 files changed, 31 insertions, 4 deletions
diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index 14cafe7b0d..c0768bba7b 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -79,6 +79,24 @@ class ModelGeneratorTest < GeneratorsTestCase end end + def test_migration_already_exists_error_message + run_generator + error = capture(:stderr){ run_generator ["Account"], :behavior => :skip } + assert_match /Another migration is already named create_accounts/, error + end + + def test_migration_error_is_not_shown_on_revoke + run_generator + error = capture(:stderr){ run_generator ["Account"], :behavior => :revoke } + assert_no_match /Another migration is already named create_accounts/, error + end + + def test_migration_is_removed_on_revoke + run_generator + run_generator ["Account"], :behavior => :revoke + assert_no_migration "db/migrate/create_accounts.rb" + end + def test_invokes_default_test_framework run_generator assert_file "test/unit/account_test.rb", /class AccountTest < ActiveSupport::TestCase/ @@ -103,8 +121,8 @@ class ModelGeneratorTest < GeneratorsTestCase protected - def run_generator(args=["Account", "name:string", "age:integer"]) - silence(:stdout) { Rails::Generators::ModelGenerator.start args, :root => destination_root } + def run_generator(args=["Account", "name:string", "age:integer"], config={}) + silence(:stdout) { Rails::Generators::ModelGenerator.start args, config.merge(:root => destination_root) } end end diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb index 53e9a1e817..a4cbb1894e 100644 --- a/railties/test/generators/resource_generator_test.rb +++ b/railties/test/generators/resource_generator_test.rb @@ -100,10 +100,19 @@ class ResourceGeneratorTest < GeneratorsTestCase assert_no_match /Plural version of the model detected/, content end + def test_route_is_removed_on_revoke + run_generator + run_generator ["account"], :behavior => :revoke + + assert_file "config/routes.rb" do |route| + assert_no_match /map\.resources :accounts$/, route + end + end + protected - def run_generator(args=["account"]) - silence(:stdout) { Rails::Generators::ResourceGenerator.start args, :root => destination_root } + def run_generator(args=["account"], config={}) + silence(:stdout) { Rails::Generators::ResourceGenerator.start args, config.merge(:root => destination_root) } end end |