Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test that the install flashcard migration is copied passes
- Loading branch information
Showing
1 changed file
with
12 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |