From d546c9c1bfada624969a71db9ef1e3686cb15c21 Mon Sep 17 00:00:00 2001 From: seenmyfate Date: Sun, 2 Jun 2013 08:49:55 +0100 Subject: [PATCH] correctly scope error message translation --- lib/capistrano/configuration/servers.rb | 8 ++++++-- lib/capistrano/i18n.rb | 2 +- spec/lib/capistrano/configuration/servers_spec.rb | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) 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