1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Properly skip test unit in 'plugin new' generator

This commit is contained in:
Piotr Sarnacki 2010-11-02 14:52:08 +01:00
parent 2133495b8c
commit fadad11f90
6 changed files with 22 additions and 26 deletions

View file

@ -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

View file

@ -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"

View file

@ -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]

View file

@ -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 file

@ -138,11 +138,6 @@ class AppGeneratorTest < Rails::Generators::TestCase
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 file

@ -35,6 +35,11 @@ module SharedGeneratorTests
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