提交 cd388e07 编写于 作者: J José Valim

Search for generators on vendorized plugins and gems.

上级 37ba0047
......@@ -20,13 +20,19 @@ module Generators
# 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
......
class MspecGenerator < Rails::Generators::NamedBase
end
......@@ -63,6 +63,12 @@ def test_find_by_namespace_lookup_traverse_folders
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 @@ def test_rails_generators_help_with_builtin_information
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册