mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Search for generators on vendorized plugins and gems.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
class StubbyGenerator < Rails::Generator::Base
|
||||
def manifest
|
||||
end
|
||||
end
|
||||
2
railties/test/fixtures/vendor/gems/mspec/lib/generators/mspec_generator.rb
vendored
Normal file
2
railties/test/fixtures/vendor/gems/mspec/lib/generators/mspec_generator.rb
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
class MspecGenerator < Rails::Generators::NamedBase
|
||||
end
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user