aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-03-13 02:47:26 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-03-13 02:47:26 +0000
commitdd665ff9679514e354336bb183a9b40ad17145fb (patch)
tree4ce55421bea5fdae8d7cbed85a33fd1434dd12a8 /railties/test
parente915379a102b5cecf0a9ffb26236dff3738d4dd7 (diff)
downloadrails-dd665ff9679514e354336bb183a9b40ad17145fb.tar.gz
rails-dd665ff9679514e354336bb183a9b40ad17145fb.tar.bz2
rails-dd665ff9679514e354336bb183a9b40ad17145fb.zip
Fixed that script/generate would not look for plugin generators in plugin_paths (closes #11000) [glv]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9017 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb4
-rw-r--r--railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb4
-rw-r--r--railties/test/generator_lookup_test.rb40
3 files changed, 48 insertions, 0 deletions
diff --git a/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb b/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb
new file mode 100644
index 0000000000..b33f2dad18
--- /dev/null
+++ b/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb
@@ -0,0 +1,4 @@
+class AGenerator < Rails::Generator::Base
+ def manifest
+ end
+end
diff --git a/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb b/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb
new file mode 100644
index 0000000000..8fda8197d1
--- /dev/null
+++ b/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb
@@ -0,0 +1,4 @@
+class StubbyGenerator < Rails::Generator::Base
+ def manifest
+ end
+end
diff --git a/railties/test/generator_lookup_test.rb b/railties/test/generator_lookup_test.rb
new file mode 100644
index 0000000000..b650f304ed
--- /dev/null
+++ b/railties/test/generator_lookup_test.rb
@@ -0,0 +1,40 @@
+require 'plugin_test_helper'
+
+class GeneratorLookupTest < Test::Unit::TestCase
+ def setup
+ @fixture_dirs = %w{alternate default}
+ @configuration = Rails.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 += @fixture_dirs.map{|fd| plugin_fixture_path(fd)}
+ @initializer = Rails::Initializer.new(@configuration)
+ @initializer.add_plugin_load_paths
+ @initializer.load_plugins
+ load 'rails_generator.rb'
+ require 'rails_generator/scripts'
+ end
+
+ def test_should_load_from_all_plugin_paths
+ assert Rails::Generator::Base.lookup('a_generator')
+ assert Rails::Generator::Base.lookup('stubby_generator')
+ end
+
+ def test_should_create_generator_source_for_each_directory_in_plugin_paths
+ sources = Rails::Generator::Base.sources
+ @fixture_dirs.each do |gen_dir|
+ expected_label = "plugins (fixtures/plugins/#{gen_dir})".to_sym
+ assert sources.any? {|source| source.label == expected_label }
+ end
+ end
+
+ def test_should_preserve_order_in_usage_message
+ msg = Rails::Generator::Scripts::Base.new.send(:usage_message)
+ positions = @fixture_dirs.map do |gen_dir|
+ pos = msg.index("Plugins (fixtures/plugins/#{gen_dir})")
+ assert_not_nil pos
+ pos
+ end
+ assert_equal positions.sort, positions
+ end
+
+end