1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Search for generators on vendorized plugins and gems.

This commit is contained in:
José Valim 2009-07-04 10:32:10 +02:00
parent 37ba0047a9
commit cd388e075c
4 changed files with 17 additions and 7 deletions

View file

@ -20,13 +20,19 @@ module Rails
# Generators load paths. First search on generators in the RAILS_ROOT, then
# look for them in rails generators.
#
# TODO Add plugins, gems and frozen gems to load path.
# TODO Right now, only plugin and frozen gems generators are loaded. Gems
# loaded by rubygems are not available since Rails dependencies system is
# being reworked.
#
def self.load_path
@@load_path ||= begin
paths = []
paths << File.expand_path(File.join(File.dirname(__FILE__), "generators"))
paths << File.join(RAILS_ROOT, "lib", "generators") if defined?(RAILS_ROOT)
if defined?(RAILS_ROOT)
paths += Dir[File.join(RAILS_ROOT, "vendor", "gems", "*", "lib", "generators")]
paths += Dir[File.join(RAILS_ROOT, "vendor", "plugins", "*", "lib", "generators")]
paths << File.join(RAILS_ROOT, "lib", "generators")
end
paths
end
end

View file

@ -1,4 +0,0 @@
class StubbyGenerator < Rails::Generator::Base
def manifest
end
end

View file

@ -0,0 +1,2 @@
class MspecGenerator < Rails::Generators::NamedBase
end

View file

@ -63,6 +63,12 @@ class GeneratorsTest < GeneratorsTestCase
assert_equal "rails:generators:javascripts", klass.namespace
end
def test_find_by_namespace_lookup_to_vendor_folders
klass = Rails::Generators.find_by_namespace(:mspec)
assert klass
assert_equal "mspec", klass.namespace
end
def test_builtin_generators
assert Rails::Generators.builtin.include? %w(rails model)
end
@ -75,7 +81,7 @@ class GeneratorsTest < GeneratorsTestCase
def test_rails_generators_with_others_information
output = capture(:stdout){ Rails::Generators.help }.split("\n").last
assert_equal "Others: active_record:fixjour, fixjour, rails:javascripts.", output
assert_equal "Others: active_record:fixjour, fixjour, mspec, rails:javascripts.", output
end
def test_no_color_sets_proper_shell