From fadad11f9056a0166ee490a5eb0a4d9a01120d38 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 2 Nov 2010 14:52:08 +0100 Subject: Properly skip test unit in 'plugin new' generator --- railties/lib/rails/generators/app_base.rb | 3 +++ .../rails/generators/rails/app/app_generator.rb | 3 --- .../rails/plugin_new/plugin_new_generator.rb | 28 +++++++++------------- .../generators/rails/plugin_new/templates/Rakefile | 4 +++- 4 files changed, 17 insertions(+), 21 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index b7a4b16f10..f5c626553c 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -47,6 +47,9 @@ module Rails class_option :edge, :type => :boolean, :default => false, :desc => "Setup the #{name} with Gemfile pointing to Rails repository" + class_option :skip_test_unit, :type => :boolean, :aliases => "-T", :default => false, + :desc => "Skip Test::Unit files" + class_option :help, :type => :boolean, :aliases => "-h", :group => :rails, :desc => "Show this help message and quit" end diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 7a6a7972d2..ef1eb8d237 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -156,9 +156,6 @@ module Rails class AppGenerator < AppBase add_shared_options_for "application" - class_option :skip_test_unit, :type => :boolean, :aliases => "-T", :default => false, - :desc => "Skip Test::Unit files" - # Add bin/rails options class_option :version, :type => :boolean, :aliases => "-v", :group => :rails, :desc => "Show Rails version number and quit" diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb index ef3ded424d..29a92c9388 100644 --- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +++ b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb @@ -142,23 +142,8 @@ end end def create_test_dummy_files - say_status :vendor_app, dummy_path - mute do - build(:generate_test_dummy) - end - end - - def change_config_files - store_application_definition! - mute do - build(:test_dummy_config) - end - end - - def remove_uneeded_rails_files - mute do - build(:test_dummy_clean) - end + return if options[:skip_test_unit] + create_test_dummy(dummy_path) end def finish_template @@ -168,6 +153,15 @@ end public_task :apply_rails_template, :bundle_if_dev_or_edge protected + def create_test_dummy(dummy_path) + say_status :vendor_app, dummy_path + mute do + build(:generate_test_dummy) + store_application_definition! + build(:test_dummy_config) + build(:test_dummy_clean) + end + end def full? options[:full] diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile index 3c53b677a0..dd7c11622d 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile +++ b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile @@ -9,9 +9,11 @@ end require 'rake' require 'rake/rdoctask' +<% unless options[:skip_test_unit] -%> <%= rakefile_test_tasks %> -task :default => :<%= test_path %> +task :default => :test +<% end -%> Rake::RDocTask.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' -- cgit v1.2.3