diff options
author | José Valim <jose.valim@gmail.com> | 2010-02-01 10:48:59 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-02-01 10:48:59 +0100 |
commit | a8c5d22c230ae46f410eed68c9b63ed31379ebbf (patch) | |
tree | e680f6d3d33f2fe0e63d4e6d94274d382029a0ae | |
parent | 209235165266ff39f2d14d02b497d7d703788104 (diff) | |
download | rails-a8c5d22c230ae46f410eed68c9b63ed31379ebbf.tar.gz rails-a8c5d22c230ae46f410eed68c9b63ed31379ebbf.tar.bz2 rails-a8c5d22c230ae46f410eed68c9b63ed31379ebbf.zip |
Add config.generators.fallbacks.
-rw-r--r-- | railties/lib/rails/configuration.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/generators.rb | 1 | ||||
-rw-r--r-- | railties/test/application/generators_test.rb | 13 |
3 files changed, 15 insertions, 2 deletions
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 6a4ebe883b..a7519397a6 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -88,11 +88,12 @@ module Rails end class Generators #:nodoc: - attr_accessor :aliases, :options, :colorize_logging + attr_accessor :aliases, :options, :fallbacks, :colorize_logging def initialize @aliases = Hash.new { |h,k| h[k] = {} } @options = Hash.new { |h,k| h[k] = {} } + @fallbacks = {} @colorize_logging = true end diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 90b513fcb4..8c54014fcb 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -67,6 +67,7 @@ module Rails no_color! unless config.colorize_logging aliases.deep_merge! config.aliases options.deep_merge! config.options + fallbacks.merge! config.fallbacks end def self.aliases #:nodoc: diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index e54edea07c..25fa100275 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -30,6 +30,7 @@ module ApplicationTests assert_equal(true, c.generators.colorize_logging) assert_equal({}, c.generators.aliases) assert_equal({}, c.generators.options) + assert_equal({}, c.generators.fallbacks) end end @@ -51,11 +52,20 @@ module ApplicationTests end end - test "generators aliases and options on initialization" do + test "generators set rails fallbacks" do + with_config do |c| + c.generators.fallbacks[:shoulda] = :test_unit + expected = { :shoulda => :test_unit } + assert_equal expected, c.generators.fallbacks + end + end + + test "generators aliases, options and fallbacks on initialization" do add_to_config <<-RUBY config.generators.rails :aliases => { :test_framework => "-w" } config.generators.orm :datamapper config.generators.test_framework :rspec + config.generators.fallbacks[:shoulda] = :test_unit RUBY # Initialize the application @@ -65,6 +75,7 @@ module ApplicationTests assert_equal :rspec, Rails::Generators.options[:rails][:test_framework] assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework] + assert_equal :test_unit, Rails::Generators.fallbacks[:shoulda] end test "generators no color on initialization" do |