Sha256: a82c350f2b74d700a6c9003853424bfdf4a532d497ac0b9dc6f90a924649fa2d

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 KB

Contents

require 'test_helper'
require_generator :data_mapper   => ['migration']

class DataMapper::Generators::MigrationGeneratorTest < Rails::Generators::TestCase
  destination File.join(Rails.root)
  tests DataMapper::Generators::MigrationGenerator

  setup :prepare_destination
  setup :copy_routes

  test "invoke with name of migration" do      
    name = 'account'    
    run_generator %w{Account}    
    migration_name = Dir[File.join(Rails.root, "db/migrate/*_#{name}.rb")].first
    if migration_name
      assert_file migration_name do |migration|      
        assert_match /up do/, migration      
        assert_match /down do/, migration
      end
    else
      fail "No migration generated for #{name}"
    end
  end

  test "invoke with name and attributes" do      
    name = 'account'    
    run_generator %w{Account name:string}    
    migration_name = Dir[File.join(Rails.root, "db/migrate/*_#{name}.rb")].first
    if migration_name
      assert_file migration_name do |migration|      
        assert_match /up do/, migration      
        assert_match /down do/, migration
        assert_match /modify_table :#{name.tableize}/, migration      
      end
    else
      fail "No migration generated for #{name}"
    end
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rails3-generators-1.0.0 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.17.6 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.17.5 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.17.4 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.17.3 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.17.2 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.17.1 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.17.0 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.16.1 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.16.0 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.15.0 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.14.0 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.13.0 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.12.1 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.12.0 test/lib/generators/data_mapper/migration_generator_test.rb
rails3-generators-0.11.0 test/lib/generators/data_mapper/migration_generator_test.rb