Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

@rctay

See #88.

@rctay rctay task(name).clear clears description/comment
The test_clear_comments test case is due to David Chelimsky
(jimweirich#88).
82f3a6e
@jimweirich jimweirich merged commit 82f3a6e into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 12, 2011
  1. @rctay

    task(name).clear clears description/comment

    rctay authored
    The test_clear_comments test case is due to David Chelimsky
    (jimweirich#88).
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 0 deletions.
  1. +8 −0 lib/rake/task.rb
  2. +16 −0 test/test_rake_task.rb
View
8 lib/rake/task.rb
@@ -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
16 test/test_rake_task.rb
@@ -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
Something went wrong with that request. Please try again.