1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Adding tests for Active Record generator

This commit is contained in:
Andrés Mejía 2010-12-10 22:17:51 +08:00 committed by José Valim
parent fe4eaf2d12
commit 60be68436b
2 changed files with 21 additions and 0 deletions

View file

@ -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

View file

@ -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__)