Permalink
Browse files

tests all pass under Ruby 1.9

  • Loading branch information...
1 parent 63aaed4 commit d558838408f425a029b4d2fd158d362dc60f9fd3 @jamis jamis committed Sep 6, 2008
View
@@ -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 @@ def namespace(name, &block)
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 @@ def task(name, options={}, &block)
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 @@ def self.plugin(name, mod)
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 @@ def close
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 @@ class RemoteDependency
def initialize(configuration)
@configuration = configuration
@success = true
+ @hosts = nil
end
def directory(path, options={})
@@ -83,7 +84,7 @@ def pass?
def message
s = @message.dup
- s << " (#{@hosts})" if @hosts && @hosts.any?
+ s << " (#{@hosts})" if @hosts
s
end
@@ -123,9 +123,9 @@ def revision_type(rev)
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,9 +119,9 @@ def update(changeset, destination)
# verbosity configuration grokking :)
def verbose
case variable(:scm_verbose)
- when nil: nil
- when false: "--quiet"
- else "--verbose"
+ when nil then nil
+ when false then "--quiet"
+ else "--verbose"
end
end
@@ -261,15 +261,16 @@ def test_should_extract_env_vars_from_command_line
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
@cli.args << "-v" << "HELLO=world" << "-f" << "foo" << "something" << "else"
@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 @@ def setup
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 @@ def test_defining_task_that_shadows_existing_task_should_not_raise_error
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,23 +59,23 @@ def test_task_with_roles_as_environment_variable_should_apply_only_to_that_role
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
ENV['HOSTS'] = "foo,bar"
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
ENV['HOSTS'] = "foo,bar"
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
View
@@ -3,7 +3,7 @@
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?

0 comments on commit d558838

Please sign in to comment.