From 790e6e815fa12b164e5af24eb975e316ffb7e1ff Mon Sep 17 00:00:00 2001 From: Bastien Vaucher Date: Mon, 8 Mar 2010 22:15:10 +0100 Subject: [PATCH] test that the install flashcard migration is copied passes --- test/flashcards_migration_generator_test.rb | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/flashcards_migration_generator_test.rb b/test/flashcards_migration_generator_test.rb index 6b4391c..2eb212f 100644 --- a/test/flashcards_migration_generator_test.rb +++ b/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 \ No newline at end of file