diff options
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 18 | ||||
-rw-r--r-- | railties/test/generators/argv_scrubber_test.rb | 4 |
2 files changed, 12 insertions, 10 deletions
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index b6dbb11a34..718be02f30 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -362,15 +362,17 @@ module Rails end end + def read_rc_file(railsrc) + return [] unless File.exists?(railsrc) + extra_args_string = File.read(railsrc) + extra_args = extra_args_string.split(/\n+/).map {|l| l.split}.flatten + puts "Using #{extra_args.join(" ")} from #{railsrc}" + extra_args + end + def insert_railsrc_into_argv!(argv, railsrc) - if File.exist?(railsrc) - extra_args_string = File.read(railsrc) - extra_args = extra_args_string.split(/\n+/).map {|l| l.split}.flatten - puts "Using #{extra_args.join(" ")} from #{railsrc}" - [argv.first] + extra_args + argv.drop(1) - else - argv - end + extra_args = read_rc_file railsrc + argv.take(1) + extra_args + argv.drop(1) end end end diff --git a/railties/test/generators/argv_scrubber_test.rb b/railties/test/generators/argv_scrubber_test.rb index 5e86acfde5..56df1cec02 100644 --- a/railties/test/generators/argv_scrubber_test.rb +++ b/railties/test/generators/argv_scrubber_test.rb @@ -67,7 +67,7 @@ module Rails define_method(:puts) { |msg| message = msg } }.new ['new'] args = scrubber.prepare! - assert_equal [nil, '--hello-world'], args + assert_equal ['--hello-world'], args assert_match 'hello-world', message assert_match file.path, message ensure @@ -85,7 +85,7 @@ module Rails define_method(:puts) { |msg| message = msg } }.new ['new', "--rc=#{file.path}"] args = scrubber.prepare! - assert_equal [nil, '--hello-world'], args + assert_equal ['--hello-world'], args assert_match 'hello-world', message assert_match file.path, message ensure |