mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Fix Style/BracesAroundHashParameters
This commit is contained in:
parent
2fde0dcafe
commit
7551f44f74
6 changed files with 39 additions and 41 deletions
|
@ -26,7 +26,7 @@ module Capistrano
|
|||
|
||||
def release_roles(*names)
|
||||
if names.last.is_a? Hash
|
||||
names.last.merge!({ :exclude => :no_release })
|
||||
names.last.merge!(:exclude => :no_release)
|
||||
else
|
||||
names << { :exclude => :no_release }
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ en = {
|
|||
}
|
||||
}
|
||||
|
||||
I18n.backend.store_translations(:en, { :capistrano => en })
|
||||
I18n.backend.store_translations(:en, :capistrano => en)
|
||||
|
||||
if I18n.respond_to?(:enforce_available_locales=)
|
||||
I18n.enforce_available_locales = true
|
||||
|
|
|
@ -103,7 +103,7 @@ describe Capistrano::DSL do
|
|||
describe "setting an internal host filter" do
|
||||
subject { dsl.roles(:app) }
|
||||
it "is ignored" do
|
||||
dsl.set :filter, { :host => "example3.com" }
|
||||
dsl.set :filter, :host => "example3.com"
|
||||
expect(subject.map(&:hostname)).to eq(["example3.com", "example4.com"])
|
||||
end
|
||||
end
|
||||
|
@ -111,7 +111,7 @@ describe Capistrano::DSL do
|
|||
describe "setting an internal role filter" do
|
||||
subject { dsl.roles(:app) }
|
||||
it "ignores it" do
|
||||
dsl.set :filter, { :role => :web }
|
||||
dsl.set :filter, :role => :web
|
||||
expect(subject.map(&:hostname)).to eq(["example3.com","example4.com"])
|
||||
end
|
||||
end
|
||||
|
@ -119,7 +119,7 @@ describe Capistrano::DSL do
|
|||
describe "setting an internal host and role filter" do
|
||||
subject { dsl.roles(:app) }
|
||||
it "ignores it" do
|
||||
dsl.set :filter, { :role => :web, :host => "example1.com" }
|
||||
dsl.set :filter, :role => :web, :host => "example1.com"
|
||||
expect(subject.map(&:hostname)).to eq(["example3.com","example4.com"])
|
||||
end
|
||||
end
|
||||
|
@ -127,7 +127,7 @@ describe Capistrano::DSL do
|
|||
describe "setting an internal regexp host filter" do
|
||||
subject { dsl.roles(:all) }
|
||||
it "is ignored" do
|
||||
dsl.set :filter, { :host => /1/ }
|
||||
dsl.set :filter, :host => /1/
|
||||
expect(subject.map(&:hostname)).to eq(%w{example1.com example2.com example3.com example4.com example5.com})
|
||||
end
|
||||
end
|
||||
|
@ -135,7 +135,7 @@ describe Capistrano::DSL do
|
|||
describe "setting an internal hosts filter" do
|
||||
subject { dsl.roles(:app) }
|
||||
it "is ignored" do
|
||||
dsl.set :filter, { :hosts => "example3.com" }
|
||||
dsl.set :filter, :hosts => "example3.com"
|
||||
expect(subject.map(&:hostname)).to eq(["example3.com", "example4.com"])
|
||||
end
|
||||
end
|
||||
|
@ -143,7 +143,7 @@ describe Capistrano::DSL do
|
|||
describe "setting an internal roles filter" do
|
||||
subject { dsl.roles(:app) }
|
||||
it "ignores it" do
|
||||
dsl.set :filter, { :roles => :web }
|
||||
dsl.set :filter, :roles => :web
|
||||
expect(subject.map(&:hostname)).to eq(["example3.com","example4.com"])
|
||||
end
|
||||
end
|
||||
|
@ -151,7 +151,7 @@ describe Capistrano::DSL do
|
|||
describe "setting an internal hosts and roles filter" do
|
||||
subject { dsl.roles(:app) }
|
||||
it "ignores it" do
|
||||
dsl.set :filter, { :roles => :web, :hosts => "example1.com" }
|
||||
dsl.set :filter, :roles => :web, :hosts => "example1.com"
|
||||
expect(subject.map(&:hostname)).to eq(["example3.com","example4.com"])
|
||||
end
|
||||
end
|
||||
|
@ -159,7 +159,7 @@ describe Capistrano::DSL do
|
|||
describe "setting an internal regexp hosts filter" do
|
||||
subject { dsl.roles(:all) }
|
||||
it "is ignored" do
|
||||
dsl.set :filter, { :hosts => /1/ }
|
||||
dsl.set :filter, :hosts => /1/
|
||||
expect(subject.map(&:hostname)).to eq(%w{example1.com example2.com example3.com example4.com example5.com})
|
||||
end
|
||||
end
|
||||
|
@ -432,11 +432,9 @@ describe Capistrano::DSL do
|
|||
dsl.set(:default_env, default_env)
|
||||
dsl.set(:pty, true)
|
||||
dsl.set(:connection_timeout, 10)
|
||||
dsl.set(:ssh_options, {
|
||||
:keys => %w(/home/user/.ssh/id_rsa),
|
||||
dsl.set(:ssh_options, :keys => %w(/home/user/.ssh/id_rsa),
|
||||
:forward_agent => false,
|
||||
:auth_methods => %w(publickey password)
|
||||
})
|
||||
:auth_methods => %w(publickey password))
|
||||
dsl.configure_backend
|
||||
end
|
||||
|
||||
|
@ -488,14 +486,14 @@ describe Capistrano::DSL do
|
|||
hosts = dsl.roles(:web)
|
||||
all = dsl.roles(:all)
|
||||
SSHKit::Coordinator.expects(:new).with(hosts).returns(@coordinator)
|
||||
dsl.set :filter, { :role => "web" }
|
||||
dsl.set :filter, :role => "web"
|
||||
dsl.on(all)
|
||||
end
|
||||
|
||||
it "filters by host and role from the :filter variable" do
|
||||
all = dsl.roles(:all)
|
||||
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
||||
dsl.set :filter, { :role => "db", :host => "example3.com" }
|
||||
dsl.set :filter, :role => "db", :host => "example3.com"
|
||||
dsl.on(all)
|
||||
end
|
||||
|
||||
|
@ -503,14 +501,14 @@ describe Capistrano::DSL do
|
|||
hosts = dsl.roles(:web)
|
||||
all = dsl.roles(:all)
|
||||
SSHKit::Coordinator.expects(:new).with(hosts).returns(@coordinator)
|
||||
dsl.set :filter, { :roles => "web" }
|
||||
dsl.set :filter, :roles => "web"
|
||||
dsl.on(all)
|
||||
end
|
||||
|
||||
it "filters by hosts and roles from the :filter variable" do
|
||||
all = dsl.roles(:all)
|
||||
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
||||
dsl.set :filter, { :roles => "db", :hosts => "example3.com" }
|
||||
dsl.set :filter, :roles => "db", :hosts => "example3.com"
|
||||
dsl.on(all)
|
||||
end
|
||||
|
||||
|
@ -550,37 +548,37 @@ describe Capistrano::DSL do
|
|||
end
|
||||
|
||||
it "selects nothing when a role filter is present" do
|
||||
dsl.set :filter, { :role => "web" }
|
||||
dsl.set :filter, :role => "web"
|
||||
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
||||
dsl.on("my.server")
|
||||
end
|
||||
|
||||
it "selects using the string when a host filter is present" do
|
||||
dsl.set :filter, { :host => "server.local" }
|
||||
dsl.set :filter, :host => "server.local"
|
||||
SSHKit::Coordinator.expects(:new).with(["server.local"]).returns(@coordinator)
|
||||
dsl.on("server.local")
|
||||
end
|
||||
|
||||
it "doesn't select when a host filter is present that doesn't match" do
|
||||
dsl.set :filter, { :host => "ruby.local" }
|
||||
dsl.set :filter, :host => "ruby.local"
|
||||
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
||||
dsl.on("server.local")
|
||||
end
|
||||
|
||||
it "selects nothing when a roles filter is present" do
|
||||
dsl.set :filter, { :roles => "web" }
|
||||
dsl.set :filter, :roles => "web"
|
||||
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
||||
dsl.on("my.server")
|
||||
end
|
||||
|
||||
it "selects using the string when a hosts filter is present" do
|
||||
dsl.set :filter, { :hosts => "server.local" }
|
||||
dsl.set :filter, :hosts => "server.local"
|
||||
SSHKit::Coordinator.expects(:new).with(["server.local"]).returns(@coordinator)
|
||||
dsl.on("server.local")
|
||||
end
|
||||
|
||||
it "doesn't select when a hosts filter is present that doesn't match" do
|
||||
dsl.set :filter, { :hosts => "ruby.local" }
|
||||
dsl.set :filter, :hosts => "ruby.local"
|
||||
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
||||
dsl.on("server.local")
|
||||
end
|
||||
|
@ -610,8 +608,8 @@ describe Capistrano::DSL do
|
|||
|
||||
it "yields the properties for a single role" do
|
||||
recipient = mock("recipient")
|
||||
recipient.expects(:doit).with("example1.com", :redis, { :port => 6379, :type => :slave})
|
||||
recipient.expects(:doit).with("example2.com", :redis, { :port => 6379, :type => :master})
|
||||
recipient.expects(:doit).with("example1.com", :redis, :port => 6379, :type => :slave)
|
||||
recipient.expects(:doit).with("example2.com", :redis, :port => 6379, :type => :master)
|
||||
dsl.role_properties(:redis) do |host, role, props|
|
||||
recipient.doit(host, role, props)
|
||||
end
|
||||
|
@ -619,8 +617,8 @@ describe Capistrano::DSL do
|
|||
|
||||
it "yields the properties for multiple roles" do
|
||||
recipient = mock("recipient")
|
||||
recipient.expects(:doit).with("example1.com", :redis, { :port => 6379, :type => :slave})
|
||||
recipient.expects(:doit).with("example2.com", :redis, { :port => 6379, :type => :master})
|
||||
recipient.expects(:doit).with("example1.com", :redis, :port => 6379, :type => :slave)
|
||||
recipient.expects(:doit).with("example2.com", :redis, :port => 6379, :type => :master)
|
||||
recipient.expects(:doit).with("example3.com", :app, nil)
|
||||
dsl.role_properties(:redis, :app) do |host, role, props|
|
||||
recipient.doit(host, role, props)
|
||||
|
@ -629,10 +627,10 @@ describe Capistrano::DSL do
|
|||
|
||||
it "yields the merged properties for multiple roles" do
|
||||
recipient = mock("recipient")
|
||||
recipient.expects(:doit).with("example1.com", :redis, { :port => 6379, :type => :slave})
|
||||
recipient.expects(:doit).with("example2.com", :redis, { :port => 6379, :type => :master})
|
||||
recipient.expects(:doit).with("example1.com", :web, { :port => 80 })
|
||||
recipient.expects(:doit).with("example2.com", :web, { :port => 81 })
|
||||
recipient.expects(:doit).with("example1.com", :redis, :port => 6379, :type => :slave)
|
||||
recipient.expects(:doit).with("example2.com", :redis, :port => 6379, :type => :master)
|
||||
recipient.expects(:doit).with("example1.com", :web, :port => 80)
|
||||
recipient.expects(:doit).with("example2.com", :web, :port => 81)
|
||||
dsl.role_properties(:redis, :web) do |host, role, props|
|
||||
recipient.doit(host, role, props)
|
||||
end
|
||||
|
@ -640,8 +638,8 @@ describe Capistrano::DSL do
|
|||
|
||||
it "honours a property filter before yielding" do
|
||||
recipient = mock("recipient")
|
||||
recipient.expects(:doit).with("example1.com", :redis, { :port => 6379, :type => :slave})
|
||||
recipient.expects(:doit).with("example1.com", :web, { :port => 80 })
|
||||
recipient.expects(:doit).with("example1.com", :redis, :port => 6379, :type => :slave)
|
||||
recipient.expects(:doit).with("example1.com", :web, :port => 80)
|
||||
dsl.role_properties(:redis, :web, :select => :active) do |host, role, props|
|
||||
recipient.doit(host, role, props)
|
||||
end
|
||||
|
|
|
@ -39,8 +39,8 @@ module Capistrano
|
|||
servers.add_host("1", :db => { :master => true })
|
||||
expect(servers.count).to eq(2)
|
||||
expect(servers.roles_for([:db]).count).to eq 2
|
||||
expect(servers.find() { |s| s.hostname == "1" }.properties.db).to eq({ :port => 1234, :master => true })
|
||||
expect(servers.find() { |s| s.hostname == "2" }.properties.db).to eq({ :port => 1234 })
|
||||
expect(servers.find() { |s| s.hostname == "1" }.properties.db).to eq(:port => 1234, :master => true)
|
||||
expect(servers.find() { |s| s.hostname == "2" }.properties.db).to eq(:port => 1234)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -89,7 +89,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
it "ignores any on_filters" do
|
||||
Configuration.env.set :filter, { :host => "1"}
|
||||
Configuration.env.set :filter, :host => "1"
|
||||
servers.add_role(:app, %w{1 2})
|
||||
servers.add_host("2", :primary => true)
|
||||
expect(servers.fetch_primary(:app).hostname).to eq("2")
|
||||
|
@ -169,7 +169,7 @@ module Capistrano
|
|||
servers.add_host("1", :roles => [:b], :db => { :port => 1234 })
|
||||
servers.add_host("1", :roles => [:b], :db => { :master => true })
|
||||
expect(servers.count).to eq(1)
|
||||
expect(servers.roles_for([:b]).first.properties.db).to eq({ :port => 1234, :master => true })
|
||||
expect(servers.roles_for([:b]).first.properties.db).to eq(:port => 1234, :master => true)
|
||||
end
|
||||
|
||||
it "concatenates previously defined array properties" do
|
||||
|
|
|
@ -262,10 +262,10 @@ module Capistrano
|
|||
it "merges them with the :ssh_options variable" do
|
||||
config.set :format, :pretty
|
||||
config.set :log_level, :debug
|
||||
config.set :ssh_options, { :user => "albert" }
|
||||
config.set :ssh_options, :user => "albert"
|
||||
SSHKit::Backend::Netssh.configure do |ssh| ssh.ssh_options = { :password => "einstein" } end
|
||||
config.configure_backend
|
||||
expect(config.backend.config.backend.config.ssh_options).to eq({ :user => "albert", :password => "einstein" })
|
||||
expect(config.backend.config.backend.config.ssh_options).to eq(:user => "albert", :password => "einstein")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ module Capistrano
|
|||
|
||||
describe '#t' do
|
||||
before do
|
||||
I18n.expects(:t).with(:phrase, {:count => 2, :scope => :capistrano})
|
||||
I18n.expects(:t).with(:phrase, :count => 2, :scope => :capistrano)
|
||||
end
|
||||
|
||||
it "delegates to I18n" do
|
||||
|
|
Loading…
Reference in a new issue