Sha256: 91f71e5113a6671edb71d3f2bb33d093349c30f02aaaae16d30ea6467cc7c2ed
Contents?: true
Size: 1.83 KB
Versions: 2
Compression:
Stored size: 1.83 KB
Contents
require 'test_helper' class GeneratorTest < ThirdBase::TestCase teardown do generated_migration_delete generated_migration_base_delete end def test_initialization_via_help output = Dir.chdir(dummy_root) { `rails g -h` } assert_match(/third_base\:migration/, output) end def test_description_uses_rails_base output = Dir.chdir(dummy_root) { `rails g third_base:migration -h` } assert_match %r{db/migrate/20080514090912_add_ssl_flag\.rb}, output end def test_migration output = Dir.chdir(dummy_root) { `rails g third_base:migration CreateFavorites post_id:integer count:integer` } assert_match %r{create.*db/thirdbase/migrate/.*create_favorites\.rb}, output migration = generated_migration_data assert_match %r{create_table :favorites}, migration assert_match %r{t.integer :post_id}, migration assert_match %r{t.integer :count}, migration end def test_base_migration_generator output = Dir.chdir(dummy_root) { `rails g migration AddBaseColumn` } assert_match %r{create.*db/migrate/.*add_base_column\.rb}, output migration = generated_migration_base_data assert_match %r{class AddBaseColumn}, migration assert_match %r{def change}, migration end private def generated_migration Dir["#{dummy_db}/thirdbase/migrate/*favorites.{rb}"].first end def generated_migration_data generated_migration ? File.read(generated_migration) : '' end def generated_migration_delete FileUtils.rm_rf(generated_migration) if generated_migration end def generated_migration_base Dir["#{dummy_db}/migrate/*add_base*.{rb}"].first end def generated_migration_base_data generated_migration_base ? File.read(generated_migration_base) : '' end def generated_migration_base_delete FileUtils.rm_rf(generated_migration_base) if generated_migration_base end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
thirdbase-2.1.2 | test/cases/generator_test.rb |
thirdbase-2.1.1 | test/cases/generator_test.rb |