diff --git a/lib/capistrano/configuration/servers.rb b/lib/capistrano/configuration/servers.rb index 20b066b8..8d92508e 100644 --- a/lib/capistrano/configuration/servers.rb +++ b/lib/capistrano/configuration/servers.rb @@ -39,8 +39,8 @@ module Capistrano # # returns the given hosts, translated to ServerDefinition objects # servers = find_servers :hosts => "jamis@example.host.com" def find_servers(options={}) - return [] if options.key?(:hosts) && (options[:hosts].nil? || options[:hosts] == []) - return [] if options.key?(:roles) && (options[:roles].nil? || options[:roles] == []) + return [] if options.key?(:hosts) && (options[:hosts].nil? || [] == options[:hosts]) + return [] if options.key?(:roles) && (options[:roles].nil? || [] == options[:roles]) hosts = server_list_from(ENV['HOSTS'] || options[:hosts]) diff --git a/test/configuration/servers_test.rb b/test/configuration/servers_test.rb index 51018878..d89f1ae0 100644 --- a/test/configuration/servers_test.rb +++ b/test/configuration/servers_test.rb @@ -159,11 +159,17 @@ class ConfigurationServersTest < Test::Unit::TestCase def test_find_servers_with_hosts_nil_or_empty assert_equal [], @config.find_servers(:hosts => nil) assert_equal [], @config.find_servers(:hosts => []) + result = @config.find_servers(:hosts => @config.find_servers(:roles => :report)[0]) + assert_equal 1, result.size + result = @config.find_servers(:hosts => "app1") + assert_equal 1, result.size end def test_find_servers_with_rolees_nil_or_empty assert_equal [], @config.find_servers(:roles => nil) assert_equal [], @config.find_servers(:roles => []) + result = @config.find_servers(:roles => :report) + assert_equal 1, result.size end end