From 648ed3b41265b3ccdba93f031486e1fdcebb5e2b Mon Sep 17 00:00:00 2001 From: Arjun Sharma Date: Sun, 14 Feb 2016 14:59:21 -0700 Subject: [PATCH] Raise error if no ORM is found during install generator --- lib/generators/devise/install_generator.rb | 1 + test/generators/install_generator_test.rb | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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