diff --git a/test/generators/active_record_generator_test.rb b/test/generators/active_record_generator_test.rb new file mode 100644 index 00000000..f7a2762f --- /dev/null +++ b/test/generators/active_record_generator_test.rb @@ -0,0 +1,20 @@ +require File.expand_path("../generators_test_helper", __FILE__) + +class ActiveRecordGeneratorTest < Rails::Generators::TestCase + tests ActiveRecord::Generators::DeviseGenerator + destination File.expand_path("../../tmp", __FILE__) + setup :prepare_destination + + test "all files are properly created" do + run_generator %w(monster) + assert_file "app/models/monster.rb", /devise/, /attr_accessible (:[a-z_]+(, )?)+/ + assert_migration "db/migrate/devise_create_monsters.rb" + end + + test "all files are properly deleted" do + run_generator %w(monster) + run_generator %w(monster), :behavior => :revoke + assert_no_file "app/models/monster.rb" + assert_no_migration "db/migrate/devise_create_monsters.rb" + end +end \ No newline at end of file diff --git a/test/generators/generators_test_helper.rb b/test/generators/generators_test_helper.rb index 7e4c555a..92853fcf 100644 --- a/test/generators/generators_test_helper.rb +++ b/test/generators/generators_test_helper.rb @@ -2,3 +2,4 @@ require "rubygems" require "rails/generators/test_case" require File.expand_path("../../../lib/generators/devise/install_generator", __FILE__) require File.expand_path("../../../lib/generators/devise/views_generator", __FILE__) +require File.expand_path("../../../lib/generators/active_record/devise_generator", __FILE__)