Skip to content

Commit

Permalink
test that the install flashcard migration is copied passes
Browse files Browse the repository at this point in the history
  • Loading branch information
bastien committed Mar 8, 2010
1 parent 4aab489 commit 790e6e8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/flashcards_migration_generator_test.rb
@@ -1,28 +1,30 @@
require File.dirname(__FILE__) + '/test_helper.rb'
require 'rails/generators'
require 'generators/flashcard/flashcard_generator'
#require 'rails/generators/scripts/generate'
#require 'rails/generators/scripts/destroy'

class MigrationGeneratorTest < Test::Unit::TestCase

def test_install_flashcard

assert File.exists?(
File.join(@destination, 'db', 'migrate', 'create_flashcards.rb')
)

# add some extra test here
FlashcardGenerator.start(["some_name_nobody_is_likely_to_ever_use_in_a_real_migration"], :destination_root => @destination)
new_file = (file_list - @original_files).first
assert_match /create_flashcards/, new_file
assert_match /create_table :some_name_nobody_is_likely_to_ever_use_in_a_real_migrations do |t|/, File.read(new_file)
end

def setup
@destination = File.join('tmp', 'test_app')
@source = FlashcardGenerator.source_root

FlashcardGenerator.start(["card"], :destination_root => @destination)
@original_files = file_list
end

def teardown
FileUtils.rm_rf(@destination)
end

private

def file_list
Dir.glob(File.join(@destination, "db", "migrate", "*"))
end

end

0 comments on commit 790e6e8

Please sign in to comment.