diff --git a/lib/generators/devise/install_generator.rb b/lib/generators/devise/install_generator.rb index d3eabbea..2717d2aa 100644 --- a/lib/generators/devise/install_generator.rb +++ b/lib/generators/devise/install_generator.rb @@ -10,6 +10,7 @@ module Devise class_option :orm def copy_initializer + raise "An ORM must be set to install Devise" unless options[:orm] template "devise.rb", "config/initializers/devise.rb" end diff --git a/test/generators/install_generator_test.rb b/test/generators/install_generator_test.rb index db63e23a..6a4657e1 100644 --- a/test/generators/install_generator_test.rb +++ b/test/generators/install_generator_test.rb @@ -6,8 +6,16 @@ class InstallGeneratorTest < Rails::Generators::TestCase setup :prepare_destination test "Assert all files are properly created" do - run_generator - assert_file "config/initializers/devise.rb" + run_generator(['--orm=active_record']) + assert_file "config/initializers/devise.rb", /devise\/orm\/active_record/ assert_file "config/locales/devise.en.yml" end + + test "Fail if no ORM is specified" do + error = assert_raises RuntimeError do + run_generator + end + + assert_match /An ORM must be set to install Devise/, error.message + end end