diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-09-29 17:41:30 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-30 09:47:06 +0200 |
commit | f851352318c7468db310e5fbea0d86dc8b731c6d (patch) | |
tree | 4d040546fdc495c1f79b580d42c1e3236e5063d1 /railties/test | |
parent | 57aa79e6bedeffcff899688546ef0a508948b4a5 (diff) | |
download | rails-f851352318c7468db310e5fbea0d86dc8b731c6d.tar.gz rails-f851352318c7468db310e5fbea0d86dc8b731c6d.tar.bz2 rails-f851352318c7468db310e5fbea0d86dc8b731c6d.zip |
Added config.app_generators to allow configuring application's generators from railties.
With config.generators becomes a way to configure generators
for current instance only. For example:
module Blog
class Engine < Rails::Engine
config.generators do |g|
g.orm :active_record
end
config.app_generators do |g|
g.test_framework :rspec
end
end
end
such definition sets :active_record as orm for engine and :rspec
as test_framework for application. The values set with app_generators
can be overwritten in application using config.generators as you would
normally do:
module MyApp
class Application < Rails::Application
config.generators do |g|
g.test_framework :test_unit
end
end
end
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/railties/engine_test.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 2b9d728b0c..c75639d740 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -703,5 +703,44 @@ module RailtiesTest get "/bukkits/bar" assert_equal "bar", last_response.body end + + test "setting generators for engine and overriding app generator's" do + @plugin.write "lib/bukkits.rb", <<-RUBY + module Bukkits + class Engine < ::Rails::Engine + config.generators do |g| + g.orm :datamapper + g.template_engine :haml + g.test_framework :rspec + end + + config.app_generators do |g| + g.orm :mongoid + g.template_engine :liquid + g.test_framework :shoulda + end + end + end + RUBY + + add_to_config <<-RUBY + config.generators do |g| + g.test_framework :test_unit + end + RUBY + + boot_rails + require "#{rails_root}/config/environment" + + app_generators = Rails.application.config.generators.options[:rails] + assert_equal :mongoid , app_generators[:orm] + assert_equal :liquid , app_generators[:template_engine] + assert_equal :test_unit, app_generators[:test_framework] + + generators = Bukkits::Engine.config.generators.options[:rails] + assert_equal :datamapper, generators[:orm] + assert_equal :haml , generators[:template_engine] + assert_equal :rspec , generators[:test_framework] + end end end |