diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-02-06 02:25:55 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-02-06 02:25:55 +0000 |
commit | b9ba2fe55059a6d9f141d1d502e16bdfd46f26cb (patch) | |
tree | 491c3ce7d406a723e5c06e3bccf4559a0de86199 /railties/test/plugin_locator_test.rb | |
parent | 97612394672203eefd04e3b1947273a3ab4ec930 (diff) | |
parent | 96d610553e5fdaabc923835ab1f194070ddb4477 (diff) | |
download | rails-b9ba2fe55059a6d9f141d1d502e16bdfd46f26cb.tar.gz rails-b9ba2fe55059a6d9f141d1d502e16bdfd46f26cb.tar.bz2 rails-b9ba2fe55059a6d9f141d1d502e16bdfd46f26cb.zip |
Merge commit 'mainstream/master'
Conflicts:
railties/guides/files/javascripts/code_highlighter.js
railties/guides/files/javascripts/guides.js
railties/guides/files/javascripts/highlighters.js
railties/guides/files/stylesheets/main.css
railties/guides/files/stylesheets/print.css
railties/guides/files/stylesheets/reset.css
railties/guides/files/stylesheets/style.css
railties/guides/files/stylesheets/syntax.css
railties/guides/rails_guides/indexer.rb
railties/guides/source/2_2_release_notes.textile
railties/guides/source/2_3_release_notes.textile
railties/guides/source/action_controller_overview.textile
railties/guides/source/action_mailer_basics.textile
railties/guides/source/active_record_basics.textile
railties/guides/source/activerecord_validations_callbacks.textile
railties/guides/source/association_basics.textile
railties/guides/source/caching_with_rails.textile
railties/guides/source/command_line.textile
railties/guides/source/debugging_rails_applications.textile
railties/guides/source/form_helpers.textile
railties/guides/source/getting_started.textile
railties/guides/source/i18n.textile
railties/guides/source/layout.html.erb
railties/guides/source/layouts_and_rendering.textile
railties/guides/source/migrations.textile
railties/guides/source/performance_testing.textile
railties/guides/source/plugins.textile
railties/guides/source/rails_on_rack.textile
railties/guides/source/routing.textile
railties/guides/source/security.textile
railties/guides/source/testing.textile
Diffstat (limited to 'railties/test/plugin_locator_test.rb')
-rw-r--r-- | railties/test/plugin_locator_test.rb | 107 |
1 files changed, 50 insertions, 57 deletions
diff --git a/railties/test/plugin_locator_test.rb b/railties/test/plugin_locator_test.rb index 5a8c651e5a..c8404e126e 100644 --- a/railties/test/plugin_locator_test.rb +++ b/railties/test/plugin_locator_test.rb @@ -1,69 +1,62 @@ require 'plugin_test_helper' -uses_mocha "Plugin Locator Tests" do - - class PluginLocatorTest < Test::Unit::TestCase - - def test_should_require_subclasses_to_implement_the_plugins_method - assert_raises(RuntimeError) do - Rails::Plugin::Locator.new(nil).plugins - end +class PluginLocatorTest < Test::Unit::TestCase + def test_should_require_subclasses_to_implement_the_plugins_method + assert_raises(RuntimeError) do + Rails::Plugin::Locator.new(nil).plugins end + end + + def test_should_iterator_over_plugins_returned_by_plugins_when_calling_each + locator = Rails::Plugin::Locator.new(nil) + locator.stubs(:plugins).returns([:a, :b, :c]) + plugin_consumer = mock + plugin_consumer.expects(:consume).with(:a) + plugin_consumer.expects(:consume).with(:b) + plugin_consumer.expects(:consume).with(:c) - def test_should_iterator_over_plugins_returned_by_plugins_when_calling_each - locator = Rails::Plugin::Locator.new(nil) - locator.stubs(:plugins).returns([:a, :b, :c]) - plugin_consumer = mock - plugin_consumer.expects(:consume).with(:a) - plugin_consumer.expects(:consume).with(:b) - plugin_consumer.expects(:consume).with(:c) - - locator.each do |plugin| - plugin_consumer.consume(plugin) - end + locator.each do |plugin| + plugin_consumer.consume(plugin) end - end +end +class PluginFileSystemLocatorTest < 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 = Rails::Plugin::FileSystemLocator.new(@initializer) + @valid_plugin_path = plugin_fixture_path('default/stubby') + @empty_plugin_path = plugin_fixture_path('default/empty') + end - class PluginFileSystemLocatorTest < 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 = Rails::Plugin::FileSystemLocator.new(@initializer) - @valid_plugin_path = plugin_fixture_path('default/stubby') - @empty_plugin_path = plugin_fixture_path('default/empty') - end + def test_should_return_rails_plugin_instances_when_calling_create_plugin_with_a_valid_plugin_directory + assert_kind_of Rails::Plugin, @locator.send(:create_plugin, @valid_plugin_path) + end - def test_should_return_rails_plugin_instances_when_calling_create_plugin_with_a_valid_plugin_directory - assert_kind_of Rails::Plugin, @locator.send(:create_plugin, @valid_plugin_path) - end - - def test_should_return_nil_when_calling_create_plugin_with_an_invalid_plugin_directory - assert_nil @locator.send(:create_plugin, @empty_plugin_path) - end - - def test_should_return_all_plugins_found_under_the_set_plugin_paths - assert_equal ["a", "acts_as_chunky_bacon", "engine", "gemlike", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort - end - - def test_should_find_plugins_only_under_the_plugin_paths_set_in_configuration - @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "default")] - assert_equal ["acts_as_chunky_bacon", "gemlike", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort - - @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "alternate")] - assert_equal ["a"], @locator.plugins.map(&:name) - end + def test_should_return_nil_when_calling_create_plugin_with_an_invalid_plugin_directory + assert_nil @locator.send(:create_plugin, @empty_plugin_path) + end + + def test_should_return_all_plugins_found_under_the_set_plugin_paths + assert_equal ["a", "acts_as_chunky_bacon", "engine", "gemlike", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort + end + + def test_should_find_plugins_only_under_the_plugin_paths_set_in_configuration + @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "default")] + assert_equal ["acts_as_chunky_bacon", "gemlike", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort - def test_should_not_raise_any_error_and_return_no_plugins_if_the_plugin_path_value_does_not_exist - @configuration.plugin_paths = ["some_missing_directory"] - assert_nothing_raised do - assert @locator.plugins.empty? - end - end + @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "alternate")] + assert_equal ["a"], @locator.plugins.map(&:name) end -end # uses_mocha + def test_should_not_raise_any_error_and_return_no_plugins_if_the_plugin_path_value_does_not_exist + @configuration.plugin_paths = ["some_missing_directory"] + assert_nothing_raised do + assert @locator.plugins.empty? + end + end +end |