From 7f698da8878b141c5324b2419d73570f507ef08f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 5 Apr 2013 16:31:19 -0700 Subject: add a class for splitting up rake commands --- railties/lib/rails/test_unit/sub_test_task.rb | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'railties/lib') diff --git a/railties/lib/rails/test_unit/sub_test_task.rb b/railties/lib/rails/test_unit/sub_test_task.rb index 36657dbdd4..ac2bde2071 100644 --- a/railties/lib/rails/test_unit/sub_test_task.rb +++ b/railties/lib/rails/test_unit/sub_test_task.rb @@ -2,6 +2,41 @@ require 'rake/testtask' module Rails class TestTask < Rake::TestTask # :nodoc: all + class TestInfo + def initialize(tasks) + @tasks = tasks + end + + def files + @tasks.find_all { |t| File.file?(t) && !File.directory?(t) } + end + + def tasks + @tasks - files - opt_names + end + + def opts + opts = opt_names + if opts.any? + "-n #{opts.join ' '}" + end + end + + private + + def opt_names + (@tasks - files).reject { |t| task_defined? t } + end + + def task_defined?(task) + Rake::Task.task_defined? task + end + end + + def self.test_info(tasks) + TestInfo.new tasks + end + def initialize(name = :test) super @libs << "test" # lib *and* test seem like a better default -- cgit v1.2.3