diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2009-11-24 21:45:14 +1100 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2009-11-24 21:45:14 +1100 |
commit | 5f2395041d1578433fa825ed5c6f26a201f2203d (patch) | |
tree | 3b78531ae77a2173ad0df1103543bdfea0b1f60f /railties/test/application/plugins_test.rb | |
parent | 3a72923e27195983d37bdb39ef26b29cf03d3483 (diff) | |
parent | e62e6d409986cd5c99234689aa49e3162d7b3a59 (diff) | |
download | rails-5f2395041d1578433fa825ed5c6f26a201f2203d.tar.gz rails-5f2395041d1578433fa825ed5c6f26a201f2203d.tar.bz2 rails-5f2395041d1578433fa825ed5c6f26a201f2203d.zip |
Merge branch 'master' of git://github.com/rails/rails into rails_master
Diffstat (limited to 'railties/test/application/plugins_test.rb')
-rw-r--r-- | railties/test/application/plugins_test.rb | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/railties/test/application/plugins_test.rb b/railties/test/application/plugins_test.rb deleted file mode 100644 index 80a19856d7..0000000000 --- a/railties/test/application/plugins_test.rb +++ /dev/null @@ -1,117 +0,0 @@ -require "isolation/abstract_unit" - -module ApplicationTests - class PluginTest < Test::Unit::TestCase - include ActiveSupport::Testing::Isolation - - def assert_plugins(list_of_names, array_of_plugins, message=nil) - assert_equal list_of_names.map { |n| n.to_s }, array_of_plugins.map { |p| p.name }, message - end - - def setup - build_app - boot_rails - require "rails" - @failure_tip = "It's likely someone has added a new plugin fixture without updating this list" - # Tmp hax to get tests working - FileUtils.cp_r "#{File.dirname(__FILE__)}/../fixtures/plugins", "#{app_path}/vendor" - end - - test "all plugins are loaded when registered plugin list is untouched" do - Rails::Initializer.run { |c| c.root = app_path } - Rails.initialize! - assert_plugins [ - :a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby - ], Rails.application.config.loaded_plugins, @failure_tip - end - - test "no plugins are loaded if the configuration has an empty plugin list" do - Rails::Initializer.run { |c| c.root = app_path; c.plugins = [] } - assert_plugins [], Rails.application.config.loaded_plugins - end - - test "only the specified plugins are located in the order listed" do - plugin_names = [:plugin_with_no_lib_dir, :acts_as_chunky_bacon] - Rails::Initializer.run { |c| c.root = app_path; c.plugins = plugin_names } - Rails.initialize! - assert_plugins plugin_names, Rails.application.config.loaded_plugins - end - - test "all plugins loaded after all" do - Rails::Initializer.run do |config| - config.root = app_path - config.plugins = [:stubby, :all, :acts_as_chunky_bacon] - end - Rails.initialize! - assert_plugins [:stubby, :a, :engine, :gemlike, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], Rails.application.config.loaded_plugins, @failure_tip - end - - test "plugin names may be strings" do - plugin_names = ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir] - Rails::Initializer.run do |config| - config.root = app_path - config.plugins = ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir] - end - Rails.initialize! - - assert_plugins plugin_names, Rails.application.config.loaded_plugins, @failure_tip - end - - test "all plugins loaded when all is used" do - Rails::Initializer.run do |config| - config.root = app_path - config.plugins = [:stubby, :acts_as_chunky_bacon, :all] - end - Rails.initialize! - - assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :engine, :gemlike, :plugin_with_no_lib_dir], Rails.application.config.loaded_plugins, @failure_tip - end - - test "all loaded plugins are added to the load paths" do - Rails::Initializer.run do |config| - config.root = app_path - config.plugins = [:stubby, :acts_as_chunky_bacon] - end - Rails.initialize! - - assert $LOAD_PATH.include?("#{app_path}/vendor/plugins/default/stubby/lib") - assert $LOAD_PATH.include?("#{app_path}/vendor/plugins/default/acts/acts_as_chunky_bacon/lib") - end - - test "registering a plugin name that does not exist raises a load error" do - Rails::Initializer.run do |config| - config.root = app_path - config.plugins = [:stubby, :acts_as_a_non_existant_plugin] - end - - assert_raise(LoadError) do - Rails.initialize! - end - end - - test "load error messages mention missing plugins and no others" do - valid_plugins = [:stubby, :acts_as_chunky_bacon] - invalid_plugins = [:non_existant_plugin1, :non_existant_plugin2] - - begin - Rails::Initializer.run do |config| - config.root = app_path - config.plugins = [:stubby, :acts_as_chunky_bacon, :non_existant_plugin1, :non_existant_plugin2] - end - Rails.initialize! - flunk "Expected a LoadError but did not get one" - rescue LoadError => e - assert_plugins valid_plugins, Rails.application.config.loaded_plugins, @failure_tip - - invalid_plugins.each do |plugin| - assert_match(/#{plugin.to_s}/, e.message, "LoadError message should mention plugin '#{plugin}'") - end - - valid_plugins.each do |plugin| - assert_no_match(/#{plugin.to_s}/, e.message, "LoadError message should not mention '#{plugin}'") - end - end - end - - end -end
\ No newline at end of file |