mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Ticket #193 - Add name assignment method to task
Needed to refactor alias_task method
This commit is contained in:
parent
fab78b2235
commit
4e211619d1
2 changed files with 19 additions and 1 deletions
|
@ -29,6 +29,11 @@ module Capistrano
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def name=(value)
|
||||
raise ArgumentError, "expected a valid task name" if !value.respond_to?(:to_sym)
|
||||
@name = value.to_sym
|
||||
end
|
||||
|
||||
# Returns the description for this task, with newlines collapsed and
|
||||
# whitespace stripped. Returns the empty string if there is no
|
||||
|
|
|
@ -25,6 +25,19 @@ class TaskDefinitionTest < Test::Unit::TestCase
|
|||
assert_equal "default", task.fully_qualified_name
|
||||
end
|
||||
|
||||
def test_name_should_change_task_name
|
||||
task = new_task(:foo)
|
||||
task.name = :bar
|
||||
|
||||
assert_equal :bar, task.name
|
||||
end
|
||||
|
||||
def test_raise_an_exception_when_task_names_can_not_be_converted
|
||||
task = new_task('valid task name')
|
||||
|
||||
assert_raises(ArgumentError) { task.name = ['invalid task name'] }
|
||||
end
|
||||
|
||||
def test_deprecation_warning_on_method_name_beginning_with_before_underscore
|
||||
name = "before_test"
|
||||
Kernel.expects(:warn).with("[Deprecation Warning] Naming tasks with before_ and after_ is deprecated, please see the new before() and after() methods. (Offending task name was #{name})")
|
||||
|
@ -113,4 +126,4 @@ class TaskDefinitionTest < Test::Unit::TestCase
|
|||
task = new_task(:testing, @namespace, :desc => "Take file.txt and copy it. Then do something else.")
|
||||
assert_equal "Take file.txt and copy it.", task.brief_description
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue