Testing Mongoid Generator Integration in Devise Framework
This test suite validates the Mongoid generator functionality for Devise authentication in Rails applications. It ensures proper model generation and cleanup when using Devise with Mongoid ORM, focusing on both creation and deletion of authentication-related files.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
heartcombo/devise
test/generators/mongoid_generator_test.rb
# frozen_string_literal: true
require "test_helper"
if DEVISE_ORM == :mongoid
require "generators/mongoid/devise_generator"
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