Permalink
Browse files

task(name).clear clears description/comment

The test_clear_comments test case is due to David Chelimsky
(jimweirich#88).
  • Loading branch information...
1 parent 47c6d8a commit 82f3a6ea38ce6514f5ac85a4e4ddd3e3f46b1eee @rctay committed Dec 12, 2011
Showing with 24 additions and 0 deletions.
  1. +8 −0 lib/rake/task.rb
  2. +16 −0 test/test_rake_task.rb
View
@@ -123,6 +123,7 @@ def reenable
def clear
clear_prerequisites
clear_actions
+ clear_comments
self
end
@@ -138,6 +139,13 @@ def clear_actions
self
end
+ # Clear the existing comments on a rake task.
+ def clear_comments
+ @full_comment = nil
+ @comment = nil
+ self
+ end
+
# Invoke the task if it is needed. Prerequisites are invoked first.
def invoke(*args)
task_args = TaskArguments.new(arg_names, args)
View
@@ -104,10 +104,12 @@ def test_can_double_invoke_with_reenable
end
def test_clear
+ desc "a task"
t = task("t" => "a") { }
t.clear
assert t.prerequisites.empty?, "prerequisites should be empty"
assert t.actions.empty?, "actions should be empty"
+ assert_nil t.comment, "comments should be empty"
end
def test_clear_prerequisites
@@ -123,6 +125,20 @@ def test_clear_actions
assert t.actions.empty?, "actions should be empty"
end
+ def test_clear_comments
+ desc "the original foo"
+ task :foo do
+ end
+
+ task(:foo).clear_comments
+
+ desc "a slightly different foo"
+ task :foo do
+ end
+
+ assert_equal "a slightly different foo", task(:foo).comment
+ end
+
def test_find
task :tfind
assert_equal "tfind", Task[:tfind].name

0 comments on commit 82f3a6e

Please sign in to comment.