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
|
||||
|
||||
* 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?
|
||||
|
||||
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"
|
||||
raise ArgumentError, "defining a namespace named `#{name}' would shadow an existing #{thing} with that name"
|
||||
end
|
||||
|
@ -92,7 +92,7 @@ module Capistrano
|
|||
raise ArgumentError, "expected a block" unless block_given?
|
||||
|
||||
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"
|
||||
raise ArgumentError, "defining a task named `#{name}' would shadow an existing #{thing} with that name"
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ module Capistrano
|
|||
Capistrano::Configuration.protected_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"
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ module Capistrano
|
|||
def log(level, message, line_prefix=nil)
|
||||
if level <= self.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
|
||||
device.puts "#{indent} [#{line_prefix}] #{line.strip}\n"
|
||||
else
|
||||
|
|
|
@ -9,6 +9,7 @@ module Capistrano
|
|||
def initialize(configuration)
|
||||
@configuration = configuration
|
||||
@success = true
|
||||
@hosts = nil
|
||||
end
|
||||
|
||||
def directory(path, options={})
|
||||
|
@ -83,7 +84,7 @@ module Capistrano
|
|||
|
||||
def message
|
||||
s = @message.dup
|
||||
s << " (#{@hosts})" if @hosts && @hosts.any?
|
||||
s << " (#{@hosts})" if @hosts
|
||||
s
|
||||
end
|
||||
|
||||
|
|
|
@ -123,9 +123,9 @@ module Capistrano
|
|||
def cvs_revision(rev)
|
||||
revision = ""
|
||||
revision << case revision_type(rev)
|
||||
when :date:
|
||||
when :date
|
||||
"-D \"#{rev}\"" if revision_type(rev) == :date
|
||||
when :revision:
|
||||
when :revision
|
||||
"-r #{rev}"
|
||||
else
|
||||
"-r #{head}"
|
||||
|
|
|
@ -119,8 +119,8 @@ module Capistrano
|
|||
# verbosity configuration grokking :)
|
||||
def verbose
|
||||
case variable(:scm_verbose)
|
||||
when nil: nil
|
||||
when false: "--quiet"
|
||||
when nil then nil
|
||||
when false then "--quiet"
|
||||
else "--verbose"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -261,7 +261,8 @@ class CLIOptionsTest < Test::Unit::TestCase
|
|||
assert_equal "world", ENV["HELLO"]
|
||||
assert_equal "value", ENV["ANOTHER"]
|
||||
ensure
|
||||
ENV["HELLO"] = ENV["ANOTHER"] = nil
|
||||
ENV.delete("HELLO")
|
||||
ENV.delete("ANOTHER")
|
||||
end
|
||||
|
||||
def test_remaining_args_should_be_added_to_actions_list
|
||||
|
@ -269,7 +270,7 @@ class CLIOptionsTest < Test::Unit::TestCase
|
|||
@cli.parse_options!
|
||||
assert_equal %w(something else), @cli.args
|
||||
ensure
|
||||
ENV["HELLO"] = nil
|
||||
ENV.delete("HELLO")
|
||||
end
|
||||
|
||||
def test_search_for_default_recipe_file_should_look_for_Capfile
|
||||
|
|
|
@ -23,7 +23,7 @@ class ConfigurationLoadingTest < Test::Unit::TestCase
|
|||
|
||||
def teardown
|
||||
MockConfig.instance = nil
|
||||
$".delete "#{File.dirname(__FILE__)}/../fixtures/custom.rb"
|
||||
$LOADED_FEATURES.delete_if { |a| a =~ /fixtures\/custom\.rb$/ }
|
||||
end
|
||||
|
||||
def test_initialize_should_init_collections
|
||||
|
|
|
@ -108,9 +108,9 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
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" }
|
||||
assert @config.methods.include?("original")
|
||||
assert @config.methods.any? { |m| m.to_sym == :original }
|
||||
end
|
||||
|
||||
def test_calling_defined_task_should_delegate_to_execute_task
|
||||
|
|
|
@ -59,7 +59,7 @@ class ConfigurationServersTest < Test::Unit::TestCase
|
|||
task = new_task(:testing)
|
||||
assert_equal %w(app1 app2 app3 file).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
|
||||
ensure
|
||||
ENV['ROLES'] = nil
|
||||
ENV.delete('ROLES')
|
||||
end
|
||||
|
||||
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)
|
||||
assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
|
||||
ensure
|
||||
ENV['HOSTS'] = nil
|
||||
ENV.delete('HOSTS')
|
||||
end
|
||||
|
||||
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)
|
||||
assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort
|
||||
ensure
|
||||
ENV['HOSTS'] = nil
|
||||
ENV.delete('HOSTS')
|
||||
end
|
||||
|
||||
def test_task_with_only_should_apply_only_to_matching_tasks
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'capistrano/role'
|
|||
|
||||
class RoleTest < Test::Unit::TestCase
|
||||
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
|
||||
role.clear
|
||||
assert role.servers.empty?
|
||||
|
|
Loading…
Reference in a new issue