1 require File.dirname(__FILE__) + '/plugin_test_helper'
3 class TestPluginFileSystemLocator < Test::Unit::TestCase
5 configuration = Rails::Configuration.new
6 # We need to add our testing plugin directory to the plugin paths so
7 # the locator knows where to look for our plugins
8 configuration.plugin_paths << plugin_fixture_root_path
9 @initializer = Rails::Initializer.new(configuration)
10 @locator = new_locator
13 def test_no_plugins_are_loaded_if_the_configuration_has_an_empty_plugin_list
14 only_load_the_following_plugins! []
15 assert_equal [], @locator.plugins
18 def test_only_the_specified_plugins_are_located_in_the_order_listed
19 plugin_names = %w(stubby acts_as_chunky_bacon)
20 only_load_the_following_plugins! plugin_names
21 assert_equal plugin_names, @locator.plugin_names
24 def test_all_plugins_are_loaded_when_registered_plugin_list_is_untouched
25 failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
26 assert_equal %w(a acts_as_chunky_bacon plugin_with_no_lib_dir stubby), @locator.plugin_names, failure_tip
30 def test_registering_a_plugin_name_that_does_not_exist_raises_a_load_error
31 only_load_the_following_plugins! %w(stubby acts_as_a_non_existant_plugin)
32 assert_raises(LoadError) do
33 @initializer.load_plugins
38 def new_locator(initializer = @initializer)
39 Rails::Plugin::FileSystemLocator.new(initializer)