diff --git a/lib/capistrano/configuration/servers.rb b/lib/capistrano/configuration/servers.rb index b86e85b2..1da30230 100644 --- a/lib/capistrano/configuration/servers.rb +++ b/lib/capistrano/configuration/servers.rb @@ -70,7 +70,7 @@ module Capistrano if servers_with_filter.any? servers_with_filter else - fail I18n.t(:filter_removes_all_servers) + fail I18n.t(:filter_removes_all_servers, scope: :capistrano, filter: key ) end end @@ -81,8 +81,12 @@ module Capistrano @servers_with_filter ||= servers.select(&filter) end + def key + options[:filter] || options[:select] + end + def filter_option - options[:filter] || options[:select] || all + key || all end def filter diff --git a/lib/capistrano/i18n.rb b/lib/capistrano/i18n.rb index a29542b8..42bcf0ca 100644 --- a/lib/capistrano/i18n.rb +++ b/lib/capistrano/i18n.rb @@ -18,7 +18,7 @@ en = { mirror_exists: "The repository mirror is at %{at}", revision_log_message: 'Branch %{branch} deployed as release %{release} by %{user}', rollback_log_message: '%{user} rolled back to release %{release}', - filter_removes_all_servers: 'Your filter %{filter} would remove all matching servers', + filter_removes_all_servers: 'Your filter `:%{filter}` would remove all matching servers', console: { welcome: 'capistrano console - enter command to execute on %{stage}', bye: 'bye' diff --git a/spec/lib/capistrano/configuration/servers_spec.rb b/spec/lib/capistrano/configuration/servers_spec.rb index cac0322a..aecab0e8 100644 --- a/spec/lib/capistrano/configuration/servers_spec.rb +++ b/spec/lib/capistrano/configuration/servers_spec.rb @@ -116,7 +116,7 @@ module Capistrano end it 'raises if the filter would remove all matching hosts' do - I18n.expects(:t).with(:filter_removes_all_servers) + I18n.expects(:t) expect { servers.roles_for([:app, select: :inactive]) }.to raise_error end @@ -137,7 +137,7 @@ module Capistrano end it 'raises if the regular proc filter would remove all matching hosts' do - I18n.expects(:t).with(:filter_removes_all_servers) + I18n.expects(:t) expect { servers.roles_for([:app, select: lambda { |h| h.properties.inactive }])}.to raise_error end