diff --git a/lib/capistrano/configuration/servers.rb b/lib/capistrano/configuration/servers.rb index 1ad78eff..a412ced4 100644 --- a/lib/capistrano/configuration/servers.rb +++ b/lib/capistrano/configuration/servers.rb @@ -42,8 +42,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 3f6b985b..6e30bb76 100644 --- a/test/configuration/servers_test.rb +++ b/test/configuration/servers_test.rb @@ -167,11 +167,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