Permalink
Browse files

making description overridable for Rake::TestTask

  • Loading branch information...
1 parent acf4328 commit fb7d1e474001bc66ada844d381b68a8e97283c65 Leo Correa and Hrvoje Šimić committed with Sep 1, 2013
Showing with 25 additions and 1 deletion.
  1. +5 −1 lib/rake/testtask.rb
  2. +10 −0 test/support/rakefile_definitions.rb
  3. +8 −0 test/test_rake_functional.rb
  4. +2 −0 test/test_rake_test_task.rb
View
@@ -67,6 +67,9 @@ class TestTask < TaskLib
# Array of commandline options to pass to ruby when running test loader.
attr_accessor :ruby_opts
+ # Description of the test task. (default is 'Run tests')
+ attr_accessor :description
+
# Explicitly define the list of test files to be included in a
# test. +list+ is expected to be an array of file names (a
# FileList is acceptable). If both +pattern+ and +test_files+ are
@@ -86,14 +89,15 @@ def initialize(name=:test)
@warning = false
@loader = :rake
@ruby_opts = []
+ @description = "Run tests" + (@name == :test ? "" : " for #{@name}")
yield self if block_given?
@pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil?
define
end
# Create the tasks defined by this task lib.
def define
- desc "Run tests" + (@name == :test ? "" : " for #{@name}")
+ desc @description
task @name do
FileUtilsExt.verbose(@verbose) do
args =
@@ -41,6 +41,16 @@ def a_top_level_function
ACCESS
end
+ def rakefile_test_task
+ rakefile <<-RAKEFILE
+ require "rake/testtask"
+
+ Rake::TestTask.new(:unit) do |t|
+ t.description = "custom test task description"
+ end
+ RAKEFILE
+ end
+
def rakefile_chains
rakefile <<-DEFAULT
task :default => "play.app"
@@ -368,6 +368,14 @@ def test_file_task_dependencies_scoped_by_namespaces
assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
end
+ def test_test_task_descriptions
+ rakefile_test_task
+
+ rake "-T"
+
+ assert_match(/custom test task description/, @out)
+ end
+
def test_comment_before_task_acts_like_desc
rakefile_comments
@@ -16,11 +16,13 @@ def test_initialize
def test_initialize_override
tt = Rake::TestTask.new(:example) do |t|
+ t.description = "Run example tests"
t.libs = ['src', 'ext']
t.pattern = 'test/tc_*.rb'
t.verbose = true
end
refute_nil tt
+ assert_equal "Run example tests", tt.description
assert_equal :example, tt.name
assert_equal ['src', 'ext'], tt.libs
assert_equal 'test/tc_*.rb', tt.pattern

0 comments on commit fb7d1e4

Please sign in to comment.