aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/plugin_locator_test.rb
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2007-03-02 23:39:29 +0000
committerMarcel Molina <marcel@vernix.org>2007-03-02 23:39:29 +0000
commit15c466dd729e744379380d08b8c25b9860fd836d (patch)
tree1adf48f88b4cb7d7d98e939584f6c3c7a304bba5 /railties/test/plugin_locator_test.rb
parentb0e1430c523cf09155f72d5996be2cc2bf8e2eb7 (diff)
downloadrails-15c466dd729e744379380d08b8c25b9860fd836d.tar.gz
rails-15c466dd729e744379380d08b8c25b9860fd836d.tar.bz2
rails-15c466dd729e744379380d08b8c25b9860fd836d.zip
Split out the basic plugin locator functionality into an abstract super class. Add a FileSystemLocator to do the job of checking the plugin_paths for plugins. Add plugin_locators configuration option which will iterate over the set of plugin locators and load each of the plugin loaders they return. Rename locater everywhere to locator. [Marcel Molina Jr.]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6290 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/test/plugin_locator_test.rb')
-rw-r--r--railties/test/plugin_locator_test.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/railties/test/plugin_locator_test.rb b/railties/test/plugin_locator_test.rb
new file mode 100644
index 0000000000..5ea89844d0
--- /dev/null
+++ b/railties/test/plugin_locator_test.rb
@@ -0,0 +1,41 @@
+require File.dirname(__FILE__) + '/plugin_test_helper'
+
+class TestPluginFileSystemLocator < Test::Unit::TestCase
+ def setup
+ configuration = Rails::Configuration.new
+ # We need to add our testing plugin directory to the plugin paths so
+ # the locator knows where to look for our plugins
+ configuration.plugin_paths << plugin_fixture_root_path
+ @initializer = Rails::Initializer.new(configuration)
+ @locator = new_locator
+ end
+
+ def test_no_plugins_are_loaded_if_the_configuration_has_an_empty_plugin_list
+ only_load_the_following_plugins! []
+ assert_equal [], @locator.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, @locator.plugin_names
+ end
+
+ def test_registering_a_plugin_name_that_does_not_exist_raises_a_load_error
+ only_load_the_following_plugins! %w(stubby acts_as_a_non_existant_plugin)
+ assert_raises(LoadError) do
+ @locator.plugins
+ 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), @locator.plugin_names, failure_tip
+ end
+
+ private
+ def new_locator(initializer = @initializer)
+ Rails::Plugin::FileSystemLocator.new(initializer)
+ end
+
+end \ No newline at end of file