mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
tests all pass under Ruby 1.9
This commit is contained in:
parent
63aaed463c
commit
d558838408
12 changed files with 26 additions and 19 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
== (unreleased)
|
||||||
|
|
||||||
|
* Ruby 1.9 compatibility [Jamis Buck]
|
||||||
|
|
||||||
|
|
||||||
== 2.5.0 / August 28, 2008
|
== 2.5.0 / August 28, 2008
|
||||||
|
|
||||||
* Allow :gateway to be set to an array, in which case a chain of tunnels is created [Kerry Buckley]
|
* Allow :gateway to be set to an array, in which case a chain of tunnels is created [Kerry Buckley]
|
||||||
|
|
|
@ -67,7 +67,7 @@ module Capistrano
|
||||||
raise ArgumentError, "expected a block" unless block_given?
|
raise ArgumentError, "expected a block" unless block_given?
|
||||||
|
|
||||||
namespace_already_defined = namespaces.key?(name)
|
namespace_already_defined = namespaces.key?(name)
|
||||||
if all_methods.include?(name.to_s) && !namespace_already_defined
|
if all_methods.any? { |m| m.to_sym == name } && !namespace_already_defined
|
||||||
thing = tasks.key?(name) ? "task" : "method"
|
thing = tasks.key?(name) ? "task" : "method"
|
||||||
raise ArgumentError, "defining a namespace named `#{name}' would shadow an existing #{thing} with that name"
|
raise ArgumentError, "defining a namespace named `#{name}' would shadow an existing #{thing} with that name"
|
||||||
end
|
end
|
||||||
|
@ -92,7 +92,7 @@ module Capistrano
|
||||||
raise ArgumentError, "expected a block" unless block_given?
|
raise ArgumentError, "expected a block" unless block_given?
|
||||||
|
|
||||||
task_already_defined = tasks.key?(name)
|
task_already_defined = tasks.key?(name)
|
||||||
if all_methods.include?(name.to_s) && !task_already_defined
|
if all_methods.any? { |m| m.to_sym == name } && !task_already_defined
|
||||||
thing = namespaces.key?(name) ? "namespace" : "method"
|
thing = namespaces.key?(name) ? "namespace" : "method"
|
||||||
raise ArgumentError, "defining a task named `#{name}' would shadow an existing #{thing} with that name"
|
raise ArgumentError, "defining a task named `#{name}' would shadow an existing #{thing} with that name"
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ module Capistrano
|
||||||
Capistrano::Configuration.protected_instance_methods +
|
Capistrano::Configuration.protected_instance_methods +
|
||||||
Capistrano::Configuration.private_instance_methods
|
Capistrano::Configuration.private_instance_methods
|
||||||
|
|
||||||
if methods.include?(name.to_s)
|
if methods.any? { |m| m.to_sym == name }
|
||||||
raise Capistrano::Error, "registering a plugin named `#{name}' would shadow a method on Capistrano::Configuration with the same name"
|
raise Capistrano::Error, "registering a plugin named `#{name}' would shadow a method on Capistrano::Configuration with the same name"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ module Capistrano
|
||||||
def log(level, message, line_prefix=nil)
|
def log(level, message, line_prefix=nil)
|
||||||
if level <= self.level
|
if level <= self.level
|
||||||
indent = "%*s" % [MAX_LEVEL, "*" * (MAX_LEVEL - level)]
|
indent = "%*s" % [MAX_LEVEL, "*" * (MAX_LEVEL - level)]
|
||||||
message.each do |line|
|
(RUBY_VERSION >= "1.9" ? message.lines : message).each do |line|
|
||||||
if line_prefix
|
if line_prefix
|
||||||
device.puts "#{indent} [#{line_prefix}] #{line.strip}\n"
|
device.puts "#{indent} [#{line_prefix}] #{line.strip}\n"
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Capistrano
|
||||||
def initialize(configuration)
|
def initialize(configuration)
|
||||||
@configuration = configuration
|
@configuration = configuration
|
||||||
@success = true
|
@success = true
|
||||||
|
@hosts = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def directory(path, options={})
|
def directory(path, options={})
|
||||||
|
@ -83,7 +84,7 @@ module Capistrano
|
||||||
|
|
||||||
def message
|
def message
|
||||||
s = @message.dup
|
s = @message.dup
|
||||||
s << " (#{@hosts})" if @hosts && @hosts.any?
|
s << " (#{@hosts})" if @hosts
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -123,9 +123,9 @@ module Capistrano
|
||||||
def cvs_revision(rev)
|
def cvs_revision(rev)
|
||||||
revision = ""
|
revision = ""
|
||||||
revision << case revision_type(rev)
|
revision << case revision_type(rev)
|
||||||
when :date:
|
when :date
|
||||||
"-D \"#{rev}\"" if revision_type(rev) == :date
|
"-D \"#{rev}\"" if revision_type(rev) == :date
|
||||||
when :revision:
|
when :revision
|
||||||
"-r #{rev}"
|
"-r #{rev}"
|
||||||
else
|
else
|
||||||
"-r #{head}"
|
"-r #{head}"
|
||||||
|
|
|
@ -119,8 +119,8 @@ module Capistrano
|
||||||
# verbosity configuration grokking :)
|
# verbosity configuration grokking :)
|
||||||
def verbose
|
def verbose
|
||||||
case variable(:scm_verbose)
|
case variable(:scm_verbose)
|
||||||
when nil: nil
|
when nil then nil
|
||||||
when false: "--quiet"
|
when false then "--quiet"
|
||||||
else "--verbose"
|
else "--verbose"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -261,7 +261,8 @@ class CLIOptionsTest < Test::Unit::TestCase
|
||||||
assert_equal "world", ENV["HELLO"]
|
assert_equal "world", ENV["HELLO"]
|
||||||
assert_equal "value", ENV["ANOTHER"]
|
assert_equal "value", ENV["ANOTHER"]
|
||||||
ensure
|
ensure
|
||||||
ENV["HELLO"] = ENV["ANOTHER"] = nil
|
ENV.delete("HELLO")
|
||||||
|
ENV.delete("ANOTHER")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_remaining_args_should_be_added_to_actions_list
|
def test_remaining_args_should_be_added_to_actions_list
|
||||||
|
@ -269,7 +270,7 @@ class CLIOptionsTest < Test::Unit::TestCase
|
||||||
@cli.parse_options!
|
@cli.parse_options!
|
||||||
assert_equal %w(something else), @cli.args
|
assert_equal %w(something else), @cli.args
|
||||||
ensure
|
ensure
|
||||||
ENV["HELLO"] = nil
|
ENV.delete("HELLO")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_search_for_default_recipe_file_should_look_for_Capfile
|
def test_search_for_default_recipe_file_should_look_for_Capfile
|
||||||
|
|
|
@ -23,7 +23,7 @@ class ConfigurationLoadingTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
MockConfig.instance = nil
|
MockConfig.instance = nil
|
||||||
$".delete "#{File.dirname(__FILE__)}/../fixtures/custom.rb"
|
$LOADED_FEATURES.delete_if { |a| a =~ /fixtures\/custom\.rb$/ }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_initialize_should_init_collections
|
def test_initialize_should_init_collections
|
||||||
|
|
|
@ -108,9 +108,9 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_defining_ask_should_add_task_as_method
|
def test_defining_ask_should_add_task_as_method
|
||||||
assert !@config.methods.include?("original")
|
assert !@config.methods.any? { |m| m.to_sym == :original }
|
||||||
@config.task(:original) { puts "foo" }
|
@config.task(:original) { puts "foo" }
|
||||||
assert @config.methods.include?("original")
|
assert @config.methods.any? { |m| m.to_sym == :original }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_calling_defined_task_should_delegate_to_execute_task
|
def test_calling_defined_task_should_delegate_to_execute_task
|
||||||
|
|
|
@ -59,7 +59,7 @@ class ConfigurationServersTest < Test::Unit::TestCase
|
||||||
task = new_task(:testing)
|
task = new_task(:testing)
|
||||||
assert_equal %w(app1 app2 app3 file).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
|
assert_equal %w(app1 app2 app3 file).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
|
||||||
ensure
|
ensure
|
||||||
ENV['ROLES'] = nil
|
ENV.delete('ROLES')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_task_with_hosts_as_environment_variable_should_apply_only_to_those_hosts
|
def test_task_with_hosts_as_environment_variable_should_apply_only_to_those_hosts
|
||||||
|
@ -67,7 +67,7 @@ class ConfigurationServersTest < Test::Unit::TestCase
|
||||||
task = new_task(:testing)
|
task = new_task(:testing)
|
||||||
assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
|
assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
|
||||||
ensure
|
ensure
|
||||||
ENV['HOSTS'] = nil
|
ENV.delete('HOSTS')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_task_with_hosts_as_environment_variable_should_not_inspect_roles_at_all
|
def test_task_with_hosts_as_environment_variable_should_not_inspect_roles_at_all
|
||||||
|
@ -75,7 +75,7 @@ class ConfigurationServersTest < Test::Unit::TestCase
|
||||||
task = new_task(:testing, @config, :roles => :bogus)
|
task = new_task(:testing, @config, :roles => :bogus)
|
||||||
assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
|
assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
|
||||||
ensure
|
ensure
|
||||||
ENV['HOSTS'] = nil
|
ENV.delete('HOSTS')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_task_with_only_should_apply_only_to_matching_tasks
|
def test_task_with_only_should_apply_only_to_matching_tasks
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'capistrano/role'
|
||||||
|
|
||||||
class RoleTest < Test::Unit::TestCase
|
class RoleTest < Test::Unit::TestCase
|
||||||
def test_clearing_a_populated_role_should_yield_no_servers
|
def test_clearing_a_populated_role_should_yield_no_servers
|
||||||
role = Capistrano::Role.new("app1.capistrano.test", lambda { "app2.capistrano.test" })
|
role = Capistrano::Role.new("app1.capistrano.test", lambda { |o| "app2.capistrano.test" })
|
||||||
assert_equal 2, role.servers.size
|
assert_equal 2, role.servers.size
|
||||||
role.clear
|
role.clear
|
||||||
assert role.servers.empty?
|
assert role.servers.empty?
|
||||||
|
|
Loading…
Reference in a new issue