Skip to content

Commit

Permalink
Properly skip test unit in 'plugin new' generator
Browse files Browse the repository at this point in the history
  • Loading branch information
drogus committed Nov 2, 2010
1 parent 2133495 commit fadad11
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
3 changes: 3 additions & 0 deletions railties/lib/rails/generators/app_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions railties/lib/rails/generators/rails/app/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 0 additions & 5 deletions railties/test/generators/app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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\(\)/
Expand Down
5 changes: 5 additions & 0 deletions railties/test/generators/shared_generator_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fadad11

Please sign in to comment.