Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Properly skip test unit in 'plugin new' generator

  • Loading branch information...
commit fadad11f9056a0166ee490a5eb0a4d9a01120d38 1 parent 2133495
@drogus authored
View
3  railties/lib/rails/generators/app_base.rb
@@ -47,6 +47,9 @@ def self.add_shared_options_for(name)
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
View
3  railties/lib/rails/generators/rails/app/app_generator.rb
@@ -156,9 +156,6 @@ module Generators
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"
View
28 railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
@@ -142,23 +142,8 @@ def create_test_files
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 @@ def finish_template
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]
View
4 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'
View
5 railties/test/generators/app_generator_test.rb
@@ -138,11 +138,6 @@ def test_prototype_and_test_unit_are_added_by_default
assert_file "test"
end
- def test_test_unit_is_skipped_if_required
- run_generator [destination_root, "--skip-test-unit"]
- assert_no_file "test"
- end
-
def test_javascript_is_skipped_if_required
run_generator [destination_root, "--skip-javascript"]
assert_file "config/application.rb", /^\s+config\.action_view\.javascript_expansions\[:defaults\]\s+=\s+%w\(\)/
View
5 railties/test/generators/shared_generator_tests.rb
@@ -35,6 +35,11 @@ def test_invalid_database_option_raises_an_error
assert_match /Invalid value for \-\-database option/, content
end
+ def test_test_unit_is_skipped_if_required
+ run_generator [destination_root, "--skip-test-unit"]
+ assert_no_file "test"
+ end
+
def test_options_before_application_name_raises_an_error
content = capture(:stderr){ run_generator(["--pretend", destination_root]) }
assert_match /Options should be given after the \w+ name. For details run: rails( plugin)? --help\n/, content

0 comments on commit fadad11

Please sign in to comment.
Something went wrong with that request. Please try again.