Permalink
Browse files

Fix loader's LoadError exception message to mention missing plugins a…

…nd omit loaded plugins.

Prior to this change the LoadError message listed all plugins if any one of them was missing.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1921 state:committed]
  • Loading branch information...
1 parent 0c95644 commit a6508527570cd3f7225a7030218447bcc5824224 Oshoma Momoh committed with NZKoz Feb 9, 2009
Showing with 21 additions and 1 deletion.
  1. +1 −1 railties/lib/rails/plugin/loader.rb
  2. +20 −0 railties/test/initializer_test.rb
@@ -175,7 +175,7 @@ def loaded?(plugin_name)
def ensure_all_registered_plugins_are_loaded!
if explicit_plugin_loading_order?
if configuration.plugins.detect {|plugin| plugin != :all && !loaded?(plugin) }
- missing_plugins = configuration.plugins - (plugins + [:all])
+ missing_plugins = configuration.plugins - (plugins.map{|p| p.name.to_sym} + [:all])
raise LoadError, "Could not locate the following plugins: #{missing_plugins.to_sentence}"
end
end
@@ -238,6 +238,26 @@ def test_registering_a_plugin_name_that_does_not_exist_raises_a_load_error
end
end
+ def test_load_error_messages_mention_missing_plugins_and_no_others
+ valid_plugin_names = [:stubby, :acts_as_chunky_bacon]
+ invalid_plugin_names = [:non_existant_plugin1, :non_existant_plugin2]
+ only_load_the_following_plugins!( valid_plugin_names + invalid_plugin_names )
+ begin
+ load_plugins!
+ flunk "Expected a LoadError but did not get one"
+ rescue LoadError => e
+ failure_tip = "It's likely someone renamed or deleted plugin fixtures without updating this test"
+ assert_plugins valid_plugin_names, @initializer.loaded_plugins, failure_tip
+ invalid_plugin_names.each do |plugin|
+ assert_match(/#{plugin.to_s}/, e.message, "LoadError message should mention plugin '#{plugin}'")
+ end
+ valid_plugin_names.each do |plugin|
+ assert_no_match(/#{plugin.to_s}/, e.message, "LoadError message should not mention '#{plugin}'")
+ end
+
+ end
+ end
+
def test_should_ensure_all_loaded_plugins_load_paths_are_added_to_the_load_path
only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]

0 comments on commit a650852

Please sign in to comment.