diff --git a/lib/alchemy/modules.rb b/lib/alchemy/modules.rb index c2c14e0492..1d9567f9a6 100644 --- a/lib/alchemy/modules.rb +++ b/lib/alchemy/modules.rb @@ -35,7 +35,7 @@ def register_module(module_definition) defined_controllers.concat(definition_hash["navigation"]["sub_navigation"].map { |x| x["controller"] }) end - validate_controllers_existence(defined_controllers) + validate_controllers_existence(defined_controllers, definition_hash) end @@alchemy_modules |= [definition_hash] @@ -43,7 +43,7 @@ def register_module(module_definition) private - def validate_controllers_existence(controllers) + def validate_controllers_existence(controllers, definition_hash) controllers.each do |controller_val| next if controller_val.blank? diff --git a/spec/libraries/modules_spec.rb b/spec/libraries/modules_spec.rb index 3c44130a9a..e0e28d7b8d 100644 --- a/spec/libraries/modules_spec.rb +++ b/spec/libraries/modules_spec.rb @@ -162,11 +162,15 @@ class ModulesTestController < ApplicationController end it "fails to register a module when a matching navigation controller cannot be found" do - expect { Modules.register_module(bad_alchemy_module_a) }.to raise_error(NameError) + expect { Modules.register_module(bad_alchemy_module_a) }.to raise_error( + "Error in AlchemyCMS module definition: 'bad_module_a'. Could not find the matching controller class BadModuleController for the specified controller: 'bad_module'" + ) end it "fails to register a module when a matching sub_navigation controller cannot be found" do - expect { Modules.register_module(bad_alchemy_module_b) }.to raise_error(NameError) + expect { Modules.register_module(bad_alchemy_module_b) }.to raise_error( + "Error in AlchemyCMS module definition: 'bad_module_b'. Could not find the matching controller class BadModuleController for the specified controller: 'bad_module'" + ) end it "registers a module definition only once" do