Raise error if no ORM is found during install generator

This commit is contained in:
Arjun Sharma
2016-02-14 14:59:21 -07:00
committed by Arjun Sharma
parent cecb3ee45b
commit 648ed3b412
2 changed files with 11 additions and 2 deletions

View File

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

View File

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