1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Make sure 'desc' applies to the next defined task, in any namespace.

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6697 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2007-05-08 04:31:43 +00:00
parent 7c4d877349
commit 845f0d2ca6
3 changed files with 18 additions and 17 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* Make sure 'desc' applies to the next defined task, in any namespace. [Jamis Buck]
* Fix shell so that servers for a task are correctly discovered. [Jamis Buck]
* Added before(), after(), and on() callback creation methods. [Jamis Buck]

View file

@ -29,7 +29,6 @@ module Capistrano
initialize_without_namespaces(*args)
@tasks = {}
@namespaces = {}
@next_description = nil
end
private :initialize_with_namespaces
@ -46,6 +45,14 @@ module Capistrano
@next_description = text
end
# Returns the value set by the last, pending "desc" call. If +reset+ is
# not false, the value will be reset immediately afterwards.
def next_description(reset=false)
@next_description
ensure
@next_description = nil if reset
end
# Open a namespace in which to define new tasks. If the namespace was
# defined previously, it will be reopened, otherwise a new namespace
# will be created for the given name.
@ -84,8 +91,7 @@ module Capistrano
raise ArgumentError, "defining a task named `#{name}' would shadow an existing #{thing} with that name"
end
tasks[name] = TaskDefinition.new(name, self, {:desc => @next_description}.merge(options), &block)
@next_description = nil
tasks[name] = TaskDefinition.new(name, self, {:desc => next_description(:reset)}.merge(options), &block)
if !task_already_defined
metaclass = class << self; self; end
@ -177,6 +183,7 @@ module Capistrano
end
include Capistrano::Configuration::Namespaces
undef :desc, :next_description
end
end
end

View file

@ -54,20 +54,6 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
assert @config.namespaces[:outer].namespaces[:inner].tasks.key?(:nested)
end
def test_pending_desc_should_disappear_when_enclosing_namespace_terminates
@config.namespace :outer do
desc "Something to say"
end
@config.namespace :outer do
task :testing do
puts "testing"
end
end
assert_nil @config.namespaces[:outer].tasks[:testing].options[:desc]
end
def test_pending_desc_should_apply_only_to_immediately_subsequent_task
@config.desc "A description"
@config.task(:testing) { puts "foo" }
@ -76,6 +62,12 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
assert_nil @config.tasks[:another].options[:desc]
end
def test_pending_desc_should_apply_only_to_next_task_in_any_namespace
@config.desc "A description"
@config.namespace(:outer) { task(:testing) { puts "foo" } }
assert_equal "A description", @config.namespaces[:outer].tasks[:testing].options[:desc]
end
def test_defining_task_without_block_should_raise_error
assert_raises(ArgumentError) do
@config.task(:testing)