Adding mongoid generator tests.

This commit is contained in:
Andrés Mejía
2010-12-10 22:51:28 +08:00
committed by José Valim
parent 60be68436b
commit a2e92a2ef2
3 changed files with 37 additions and 15 deletions

View File

@@ -1,20 +1,22 @@
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
if DEVISE_ORM == :active_record
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 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"
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
end

View File

@@ -2,4 +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__)
require File.expand_path("../../../lib/generators/#{DEVISE_ORM}/devise_generator", __FILE__)

View File

@@ -0,0 +1,20 @@
require File.expand_path("../generators_test_helper", __FILE__)
if DEVISE_ORM == :mongoid
class MongoidGeneratorTest < Rails::Generators::TestCase
tests Mongoid::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/
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"
end
end
end