aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/plugin_locater_test.rb
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2007-03-02 00:20:32 +0000
committerMarcel Molina <marcel@vernix.org>2007-03-02 00:20:32 +0000
commitb0e1430c523cf09155f72d5996be2cc2bf8e2eb7 (patch)
treec1f0dfd39794fa284737386f6c7520529e581b3b /railties/test/plugin_locater_test.rb
parent36cf67e8e50056e178f2d43705a324778fddfd0f (diff)
downloadrails-b0e1430c523cf09155f72d5996be2cc2bf8e2eb7.tar.gz
rails-b0e1430c523cf09155f72d5996be2cc2bf8e2eb7.tar.bz2
rails-b0e1430c523cf09155f72d5996be2cc2bf8e2eb7.zip
Split plugin location and loading out of the initializer and into a new Plugin namespace, which includes Plugin::Locater and Plugin::Loader. The loader class that is used can be customized using the config.plugin_loader option. Those monkey patching the plugin loading subsystem take note, the internals changing here will likely break your modifications. The good news is that it should be substantially easier to hook into the plugin locating and loading process now. [Marcel Molina Jr.]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6277 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/test/plugin_locater_test.rb')
-rw-r--r--railties/test/plugin_locater_test.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/railties/test/plugin_locater_test.rb b/railties/test/plugin_locater_test.rb
new file mode 100644
index 0000000000..ba843a8e45
--- /dev/null
+++ b/railties/test/plugin_locater_test.rb
@@ -0,0 +1,51 @@
+require File.dirname(__FILE__) + '/plugin_test_helper'
+
+class TestPluginLocater < Test::Unit::TestCase
+ def setup
+ configuration = Rails::Configuration.new
+ # We need to add our testing plugin directory to the plugin paths so
+ # the locater knows where to look for our plugins
+ configuration.plugin_paths << plugin_fixture_root_path
+ @initializer = Rails::Initializer.new(configuration)
+ @locater = new_locater
+ end
+
+ def test_determining_if_the_plugin_order_has_been_explicitly_set
+ assert !@locater.send(:explicit_plugin_loading_order?)
+ only_load_the_following_plugins! %w(stubby acts_as_chunky_bacon)
+ assert @locater.send(:explicit_plugin_loading_order?)
+ end
+
+ def test_no_plugins_are_loaded_if_the_configuration_has_an_empty_plugin_list
+ only_load_the_following_plugins! []
+ assert_equal [], @locater.plugins
+ end
+
+ def test_only_the_specified_plugins_are_located_in_the_order_listed
+ plugin_names = %w(stubby acts_as_chunky_bacon)
+ only_load_the_following_plugins! plugin_names
+ assert_equal plugin_names, @locater.plugin_names
+ end
+
+ def test_registering_a_plugin_name_that_does_not_exist_raisesa_load_error
+ only_load_the_following_plugins! %w(stubby acts_as_non_existant_plugin)
+ assert_raises(LoadError) do
+ @locater.plugin_names
+ end
+ end
+
+ def test_all_plugins_are_loaded_when_registered_plugin_list_is_untouched
+ failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
+ assert_equal %w(a acts_as_chunky_bacon plugin_with_no_lib_dir stubby), @locater.plugin_names, failure_tip
+ end
+
+ private
+ def new_locater(initializer = @initializer)
+ Rails::Plugin::Locater.new(initializer)
+ end
+
+ def only_load_the_following_plugins!(plugins)
+ @initializer.configuration.plugins = plugins
+ end
+
+end \ No newline at end of file