task(name).clear clears description/comment #97

Merged
merged 1 commit into from Oct 17, 2012
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)
@@ -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