mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Merge pull request #1597 from will-in-wi/rubocop_hash_rockets
Default to Ruby 1.9 syntax for hashes
This commit is contained in:
commit
17530ccc38
24 changed files with 220 additions and 222 deletions
|
@ -9,8 +9,6 @@ Style/ClassAndModuleChildren:
|
|||
Enabled: false
|
||||
Style/DoubleNegation:
|
||||
Enabled: false
|
||||
Style/HashSyntax:
|
||||
EnforcedStyle: hash_rockets
|
||||
Style/SpaceAroundEqualsInParameterDefault:
|
||||
EnforcedStyle: no_space
|
||||
Style/StringLiterals:
|
||||
|
|
2
Rakefile
2
Rakefile
|
@ -3,7 +3,7 @@ require "cucumber/rake/task"
|
|||
require "rspec/core/rake_task"
|
||||
require "rubocop/rake_task"
|
||||
|
||||
task :default => [:spec, :rubocop]
|
||||
task default: [:spec, :rubocop]
|
||||
RSpec::Core::RakeTask.new
|
||||
|
||||
Cucumber::Rake::Task.new(:features)
|
||||
|
|
|
@ -46,7 +46,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
def question
|
||||
I18n.t(:question, :key => key, :default_value => default, :scope => :capistrano)
|
||||
I18n.t(:question, key: key, default_value: default, scope: :capistrano)
|
||||
end
|
||||
|
||||
def echo?
|
||||
|
|
|
@ -18,7 +18,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
def add_role(role, hosts, options={})
|
||||
options_deepcopy = Marshal.dump(options.merge(:roles => role))
|
||||
options_deepcopy = Marshal.dump(options.merge(roles: role))
|
||||
Array(hosts).each { |host| add_host(host, Marshal.load(options_deepcopy)) }
|
||||
end
|
||||
|
||||
|
@ -37,7 +37,7 @@ module Capistrano
|
|||
if block_given?
|
||||
yield host, role, props
|
||||
else
|
||||
rps << (props || {}).merge(:role => role, :hostname => host.hostname)
|
||||
rps << (props || {}).merge(role: role, hostname: host.hostname)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
def t(key, options={})
|
||||
I18n.t(key, options.merge(:scope => :capistrano))
|
||||
I18n.t(key, options.merge(scope: :capistrano))
|
||||
end
|
||||
|
||||
def scm
|
||||
|
@ -30,15 +30,15 @@ module Capistrano
|
|||
def revision_log_message
|
||||
fetch(:revision_log_message,
|
||||
t(:revision_log_message,
|
||||
:branch => fetch(:branch),
|
||||
:user => local_user,
|
||||
:sha => fetch(:current_revision),
|
||||
:release => fetch(:release_timestamp))
|
||||
branch: fetch(:branch),
|
||||
user: local_user,
|
||||
sha: fetch(:current_revision),
|
||||
release: fetch(:release_timestamp))
|
||||
)
|
||||
end
|
||||
|
||||
def rollback_log_message
|
||||
t(:rollback_log_message, :user => local_user, :release => fetch(:rollback_timestamp))
|
||||
t(:rollback_log_message, user: local_user, release: fetch(:rollback_timestamp))
|
||||
end
|
||||
|
||||
def local_user
|
||||
|
|
|
@ -28,7 +28,7 @@ module Capistrano
|
|||
if names.last.is_a? Hash
|
||||
names.last[:exclude] = :no_release
|
||||
else
|
||||
names << { :exclude => :no_release }
|
||||
names << { exclude: :no_release }
|
||||
end
|
||||
roles(*names)
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
def exit_deploy_because_of_exception(ex)
|
||||
warn t(:deploy_failed, :ex => ex.message)
|
||||
warn t(:deploy_failed, ex: ex.message)
|
||||
invoke "deploy:failed"
|
||||
exit(false)
|
||||
end
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
require "i18n"
|
||||
|
||||
en = {
|
||||
:starting => "Starting",
|
||||
:capified => "Capified",
|
||||
:start => "Start",
|
||||
:update => "Update",
|
||||
:finalize => "Finalise",
|
||||
:finishing => "Finishing",
|
||||
:finished => "Finished",
|
||||
:stage_not_set => "Stage not set, please call something such as `cap production deploy`, where production is a stage you have defined.",
|
||||
:written_file => "create %{file}",
|
||||
:question => "Please enter %{key} (%{default_value}): ",
|
||||
:keeping_releases => "Keeping %{keep_releases} of %{releases} deployed releases on %{host}",
|
||||
:no_old_releases => "No old releases (keeping newest %{keep_releases}) on %{host}",
|
||||
:linked_file_does_not_exist => "linked file %{file} does not exist on %{host}",
|
||||
:cannot_rollback => "There are no older releases to rollback to",
|
||||
:mirror_exists => "The repository mirror is at %{at}",
|
||||
:revision_log_message => "Branch %{branch} (at %{sha}) deployed as release %{release} by %{user}",
|
||||
:rollback_log_message => "%{user} rolled back to release %{release}",
|
||||
:deploy_failed => "The deploy has failed with an error: %{ex}",
|
||||
:console => {
|
||||
:welcome => "capistrano console - enter command to execute on %{stage}",
|
||||
:bye => "bye"
|
||||
starting: "Starting",
|
||||
capified: "Capified",
|
||||
start: "Start",
|
||||
update: "Update",
|
||||
finalize: "Finalise",
|
||||
finishing: "Finishing",
|
||||
finished: "Finished",
|
||||
stage_not_set: "Stage not set, please call something such as `cap production deploy`, where production is a stage you have defined.",
|
||||
written_file: "create %{file}",
|
||||
question: "Please enter %{key} (%{default_value}): ",
|
||||
keeping_releases: "Keeping %{keep_releases} of %{releases} deployed releases on %{host}",
|
||||
no_old_releases: "No old releases (keeping newest %{keep_releases}) on %{host}",
|
||||
linked_file_does_not_exist: "linked file %{file} does not exist on %{host}",
|
||||
cannot_rollback: "There are no older releases to rollback to",
|
||||
mirror_exists: "The repository mirror is at %{at}",
|
||||
revision_log_message: "Branch %{branch} (at %{sha}) deployed as release %{release} by %{user}",
|
||||
rollback_log_message: "%{user} rolled back to release %{release}",
|
||||
deploy_failed: "The deploy has failed with an error: %{ex}",
|
||||
console: {
|
||||
welcome: "capistrano console - enter command to execute on %{stage}",
|
||||
bye: "bye"
|
||||
},
|
||||
:error => {
|
||||
:user => {
|
||||
:does_not_exist => "User %{user} does not exists",
|
||||
:cannot_switch => "Cannot switch to user %{user}"
|
||||
error: {
|
||||
user: {
|
||||
does_not_exist: "User %{user} does not exists",
|
||||
cannot_switch: "Cannot switch to user %{user}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
desc "Execute remote commands"
|
||||
task :console do
|
||||
stage = fetch(:stage)
|
||||
puts I18n.t("console.welcome", :scope => :capistrano, :stage => stage)
|
||||
puts I18n.t("console.welcome", scope: :capistrano, stage: stage)
|
||||
loop do
|
||||
print "#{stage}> "
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace :deploy do
|
|||
puts
|
||||
end
|
||||
|
||||
task :updating => :new_release_path do
|
||||
task updating: :new_release_path do
|
||||
invoke "#{scm}:create_release"
|
||||
invoke "deploy:set_current_revision"
|
||||
invoke "deploy:symlink:shared"
|
||||
|
@ -90,7 +90,7 @@ namespace :deploy do
|
|||
on release_roles :all do |host|
|
||||
linked_files(shared_path).each do |file|
|
||||
unless test "[ -f #{file} ]"
|
||||
error t(:linked_file_does_not_exist, :file => file, :host => host)
|
||||
error t(:linked_file_does_not_exist, file: file, host: host)
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
@ -152,7 +152,7 @@ namespace :deploy do
|
|||
on release_roles :all do |host|
|
||||
releases = capture(:ls, "-xtr", releases_path).split
|
||||
if releases.count >= fetch(:keep_releases)
|
||||
info t(:keeping_releases, :host => host.to_s, :keep_releases => fetch(:keep_releases), :releases => releases.count)
|
||||
info t(:keeping_releases, host: host.to_s, keep_releases: fetch(:keep_releases), releases: releases.count)
|
||||
directories = (releases - releases.last(fetch(:keep_releases)))
|
||||
if directories.any?
|
||||
directories_str = directories.map do |release|
|
||||
|
@ -160,7 +160,7 @@ namespace :deploy do
|
|||
end.join(" ")
|
||||
execute :rm, "-rf", directories_str
|
||||
else
|
||||
info t(:no_old_releases, :host => host.to_s, :keep_releases => fetch(:keep_releases))
|
||||
info t(:no_old_releases, host: host.to_s, keep_releases: fetch(:keep_releases))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -192,7 +192,7 @@ namespace :deploy do
|
|||
end
|
||||
|
||||
desc "Revert to previous release timestamp"
|
||||
task :revert_release => :rollback_release_path do
|
||||
task revert_release: :rollback_release_path do
|
||||
on release_roles(:all) do
|
||||
set(:revision_log_message, rollback_log_message)
|
||||
end
|
||||
|
|
|
@ -64,4 +64,4 @@ task :deploy do
|
|||
invoke "deploy:#{task}"
|
||||
end
|
||||
end
|
||||
task :default => :deploy
|
||||
task default: :deploy
|
||||
|
|
|
@ -5,8 +5,8 @@ namespace :git do
|
|||
|
||||
set :git_environmental_variables, lambda {
|
||||
{
|
||||
:git_askpass => "/bin/echo",
|
||||
:git_ssh => "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
|
||||
git_askpass: "/bin/echo",
|
||||
git_ssh: "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace :git do
|
|||
end
|
||||
|
||||
desc "Check that the repository is reachable"
|
||||
task :check => :'git:wrapper' do
|
||||
task check: :'git:wrapper' do
|
||||
fetch(:branch)
|
||||
on release_roles :all do
|
||||
with fetch(:git_environmental_variables) do
|
||||
|
@ -30,10 +30,10 @@ namespace :git do
|
|||
end
|
||||
|
||||
desc "Clone the repo to the cache"
|
||||
task :clone => :'git:wrapper' do
|
||||
task clone: :'git:wrapper' do
|
||||
on release_roles :all do
|
||||
if strategy.test
|
||||
info t(:mirror_exists, :at => repo_path)
|
||||
info t(:mirror_exists, at: repo_path)
|
||||
else
|
||||
within deploy_path do
|
||||
with fetch(:git_environmental_variables) do
|
||||
|
@ -45,7 +45,7 @@ namespace :git do
|
|||
end
|
||||
|
||||
desc "Update the repo mirror to reflect the origin state"
|
||||
task :update => :'git:clone' do
|
||||
task update: :'git:clone' do
|
||||
on release_roles :all do
|
||||
within repo_path do
|
||||
with fetch(:git_environmental_variables) do
|
||||
|
@ -56,7 +56,7 @@ namespace :git do
|
|||
end
|
||||
|
||||
desc "Copy repo to releases"
|
||||
task :create_release => :'git:update' do
|
||||
task create_release: :'git:update' do
|
||||
on release_roles :all do
|
||||
with fetch(:git_environmental_variables) do
|
||||
within repo_path do
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace :hg do
|
|||
task :clone do
|
||||
on release_roles :all do
|
||||
if strategy.test
|
||||
info t(:mirror_exists, :at => repo_path)
|
||||
info t(:mirror_exists, at: repo_path)
|
||||
else
|
||||
within deploy_path do
|
||||
strategy.clone
|
||||
|
@ -24,7 +24,7 @@ namespace :hg do
|
|||
end
|
||||
|
||||
desc "Pull changes from the remote repo"
|
||||
task :update => :'hg:clone' do
|
||||
task update: :'hg:clone' do
|
||||
on release_roles :all do
|
||||
within repo_path do
|
||||
strategy.update
|
||||
|
@ -33,7 +33,7 @@ namespace :hg do
|
|||
end
|
||||
|
||||
desc "Copy repo to releases"
|
||||
task :create_release => :'hg:update' do
|
||||
task create_release: :'hg:update' do
|
||||
on release_roles :all do
|
||||
within repo_path do
|
||||
strategy.release
|
||||
|
|
|
@ -14,8 +14,8 @@ task :install do
|
|||
|
||||
mkdir_p deploy_dir
|
||||
|
||||
entries = [{ :template => deploy_rb, :file => config_dir.join("deploy.rb") }]
|
||||
entries += envs.split(",").map { |stage| { :template => stage_rb, :file => deploy_dir.join("#{stage}.rb") } }
|
||||
entries = [{ template: deploy_rb, file: config_dir.join("deploy.rb") }]
|
||||
entries += envs.split(",").map { |stage| { template: stage_rb, file: deploy_dir.join("#{stage}.rb") } }
|
||||
|
||||
entries.each do |entry|
|
||||
if File.exist?(entry[:file])
|
||||
|
@ -23,7 +23,7 @@ task :install do
|
|||
else
|
||||
File.open(entry[:file], "w+") do |f|
|
||||
f.write(ERB.new(File.read(entry[:template])).result(binding))
|
||||
puts I18n.t(:written_file, :scope => :capistrano, :file => entry[:file])
|
||||
puts I18n.t(:written_file, scope: :capistrano, file: entry[:file])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -34,8 +34,8 @@ task :install do
|
|||
warn "[skip] Capfile already exists"
|
||||
else
|
||||
FileUtils.cp(capfile, "Capfile")
|
||||
puts I18n.t(:written_file, :scope => :capistrano, :file => "Capfile")
|
||||
puts I18n.t(:written_file, scope: :capistrano, file: "Capfile")
|
||||
end
|
||||
|
||||
puts I18n.t :capified, :scope => :capistrano
|
||||
puts I18n.t :capified, scope: :capistrano
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace :svn do
|
|||
task :clone do
|
||||
on release_roles :all do
|
||||
if strategy.test
|
||||
info t(:mirror_exists, :at => repo_path)
|
||||
info t(:mirror_exists, at: repo_path)
|
||||
else
|
||||
within deploy_path do
|
||||
strategy.clone
|
||||
|
@ -24,7 +24,7 @@ namespace :svn do
|
|||
end
|
||||
|
||||
desc "Pull changes from the remote repo"
|
||||
task :update => :'svn:clone' do
|
||||
task update: :'svn:clone' do
|
||||
on release_roles :all do
|
||||
within repo_path do
|
||||
strategy.update
|
||||
|
@ -33,7 +33,7 @@ namespace :svn do
|
|||
end
|
||||
|
||||
desc "Copy repo to releases"
|
||||
task :create_release => :'svn:update' do
|
||||
task create_release: :'svn:update' do
|
||||
on release_roles :all do
|
||||
within repo_path do
|
||||
strategy.release
|
||||
|
|
|
@ -10,11 +10,11 @@ describe Capistrano::DSL do
|
|||
describe "setting and fetching hosts" do
|
||||
describe "when defining a host using the `server` syntax" do
|
||||
before do
|
||||
dsl.server "example1.com", :roles => %w{web}, :active => true
|
||||
dsl.server "example2.com", :roles => %w{web}
|
||||
dsl.server "example3.com", :roles => %w{app web}, :active => true
|
||||
dsl.server "example4.com", :roles => %w{app}, :primary => true
|
||||
dsl.server "example5.com", :roles => %w{db}, :no_release => true, :active => true
|
||||
dsl.server "example1.com", roles: %w{web}, active: true
|
||||
dsl.server "example2.com", roles: %w{web}
|
||||
dsl.server "example3.com", roles: %w{app web}, active: true
|
||||
dsl.server "example4.com", roles: %w{app}, primary: true
|
||||
dsl.server "example5.com", roles: %w{db}, no_release: true, active: true
|
||||
end
|
||||
|
||||
describe "fetching all servers" do
|
||||
|
@ -35,7 +35,7 @@ describe Capistrano::DSL do
|
|||
end
|
||||
|
||||
context "with property filter options" do
|
||||
subject { dsl.release_roles(:all, :filter => :active) }
|
||||
subject { dsl.release_roles(:all, filter: :active) }
|
||||
|
||||
it "returns all release servers that match the property filter" do
|
||||
expect(subject.map(&:hostname)).to eq %w{example1.com example3.com}
|
||||
|
@ -46,7 +46,7 @@ describe Capistrano::DSL do
|
|||
describe "fetching servers by multiple roles" do
|
||||
it "does not confuse the last role with options" do
|
||||
expect(dsl.roles(:app, :web).count).to eq 4
|
||||
expect(dsl.roles(:app, :web, :filter => :active).count).to eq 2
|
||||
expect(dsl.roles(:app, :web, filter: :active).count).to eq 2
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -67,7 +67,7 @@ describe Capistrano::DSL do
|
|||
end
|
||||
|
||||
describe "fetching filtered servers by role" do
|
||||
subject { dsl.roles(:app, :filter => :active) }
|
||||
subject { dsl.roles(:app, filter: :active) }
|
||||
|
||||
it "returns the servers" do
|
||||
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
||||
|
@ -75,7 +75,7 @@ describe Capistrano::DSL do
|
|||
end
|
||||
|
||||
describe "fetching selected servers by role" do
|
||||
subject { dsl.roles(:app, :select => :active) }
|
||||
subject { dsl.roles(:app, select: :active) }
|
||||
|
||||
it "returns the servers" do
|
||||
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
||||
|
@ -101,7 +101,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
|
||||
|
@ -109,7 +109,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
|
||||
|
@ -117,7 +117,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
|
||||
|
@ -125,7 +125,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
|
||||
|
@ -133,7 +133,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
|
||||
|
@ -141,7 +141,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
|
||||
|
@ -149,7 +149,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
|
||||
|
@ -157,7 +157,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
|
||||
|
@ -174,11 +174,11 @@ describe Capistrano::DSL do
|
|||
describe "when defining hosts using the `role` syntax" do
|
||||
before do
|
||||
dsl.role :web, %w{example1.com example2.com example3.com}
|
||||
dsl.role :web, %w{example1.com}, :active => true
|
||||
dsl.role :web, %w{example1.com}, active: true
|
||||
dsl.role :app, %w{example3.com example4.com}
|
||||
dsl.role :app, %w{example3.com}, :active => true
|
||||
dsl.role :app, %w{example4.com}, :primary => true
|
||||
dsl.role :db, %w{example5.com}, :no_release => true
|
||||
dsl.role :app, %w{example3.com}, active: true
|
||||
dsl.role :app, %w{example4.com}, primary: true
|
||||
dsl.role :db, %w{example5.com}, no_release: true
|
||||
end
|
||||
|
||||
describe "fetching all servers" do
|
||||
|
@ -199,7 +199,7 @@ describe Capistrano::DSL do
|
|||
end
|
||||
|
||||
context "with filter options" do
|
||||
subject { dsl.release_roles(:all, :filter => :active) }
|
||||
subject { dsl.release_roles(:all, filter: :active) }
|
||||
|
||||
it "returns all release servers that match the filter" do
|
||||
expect(subject.map(&:hostname)).to eq %w{example1.com example3.com}
|
||||
|
@ -224,7 +224,7 @@ describe Capistrano::DSL do
|
|||
end
|
||||
|
||||
describe "fetching filtered servers by role" do
|
||||
subject { dsl.roles(:app, :filter => :active) }
|
||||
subject { dsl.roles(:app, filter: :active) }
|
||||
|
||||
it "returns the servers" do
|
||||
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
||||
|
@ -232,7 +232,7 @@ describe Capistrano::DSL do
|
|||
end
|
||||
|
||||
describe "fetching selected servers by role" do
|
||||
subject { dsl.roles(:app, :select => :active) }
|
||||
subject { dsl.roles(:app, select: :active) }
|
||||
|
||||
it "returns the servers" do
|
||||
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
||||
|
@ -258,9 +258,9 @@ describe Capistrano::DSL do
|
|||
|
||||
describe "when defining a host using a combination of the `server` and `role` syntax" do
|
||||
before do
|
||||
dsl.server "db@example1.com:1234", :roles => %w{db}, :active => true
|
||||
dsl.server "root@example1.com:1234", :roles => %w{web}, :active => true
|
||||
dsl.server "example1.com:5678", :roles => %w{web}, :active => true
|
||||
dsl.server "db@example1.com:1234", roles: %w{db}, active: true
|
||||
dsl.server "root@example1.com:1234", roles: %w{web}, active: true
|
||||
dsl.server "example1.com:5678", roles: %w{web}, active: true
|
||||
dsl.role :app, %w{deployer@example1.com:1234}
|
||||
dsl.role :app, %w{example1.com:5678}
|
||||
end
|
||||
|
@ -293,14 +293,14 @@ describe Capistrano::DSL do
|
|||
|
||||
describe "using the :user property" do
|
||||
it "takes precedence over in the host string" do
|
||||
dsl.server "db@example1.com:1234", :roles => %w{db}, :active => true, :user => "brian"
|
||||
dsl.server "db@example1.com:1234", roles: %w{db}, active: true, user: "brian"
|
||||
expect(subject).to eq("brian@example1.com:1234")
|
||||
end
|
||||
end
|
||||
|
||||
describe "using the :port property" do
|
||||
it "takes precedence over in the host string" do
|
||||
dsl.server "db@example1.com:9090", :roles => %w{db}, :active => true, :port => 1234
|
||||
dsl.server "db@example1.com:9090", roles: %w{db}, active: true, port: 1234
|
||||
expect(subject).to eq("db@example1.com:1234")
|
||||
end
|
||||
end
|
||||
|
@ -414,7 +414,7 @@ describe Capistrano::DSL do
|
|||
describe "configuration SSHKit" do
|
||||
let(:config) { SSHKit.config }
|
||||
let(:backend) { SSHKit.config.backend.config }
|
||||
let(:default_env) { { :rails_env => :production } }
|
||||
let(:default_env) { { rails_env: :production } }
|
||||
|
||||
before do
|
||||
dsl.set(:format, :dot)
|
||||
|
@ -422,9 +422,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),
|
||||
:forward_agent => false,
|
||||
:auth_methods => %w(publickey password))
|
||||
dsl.set(:ssh_options, keys: %w(/home/user/.ssh/id_rsa),
|
||||
forward_agent: false,
|
||||
auth_methods: %w(publickey password))
|
||||
dsl.configure_backend
|
||||
end
|
||||
|
||||
|
@ -458,11 +458,11 @@ describe Capistrano::DSL do
|
|||
describe "on()" do
|
||||
describe "when passed server objects" do
|
||||
before do
|
||||
dsl.server "example1.com", :roles => %w{web}, :active => true
|
||||
dsl.server "example2.com", :roles => %w{web}
|
||||
dsl.server "example3.com", :roles => %w{app web}, :active => true
|
||||
dsl.server "example4.com", :roles => %w{app}, :primary => true
|
||||
dsl.server "example5.com", :roles => %w{db}, :no_release => true
|
||||
dsl.server "example1.com", roles: %w{web}, active: true
|
||||
dsl.server "example2.com", roles: %w{web}
|
||||
dsl.server "example3.com", roles: %w{app web}, active: true
|
||||
dsl.server "example4.com", roles: %w{app}, primary: true
|
||||
dsl.server "example5.com", roles: %w{db}, no_release: true
|
||||
@coordinator = mock("coordinator")
|
||||
@coordinator.expects(:each).returns(nil)
|
||||
ENV.delete "ROLES"
|
||||
|
@ -473,14 +473,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
|
||||
|
||||
|
@ -488,14 +488,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
|
||||
|
||||
|
@ -533,37 +533,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
|
||||
|
@ -572,26 +572,26 @@ describe Capistrano::DSL do
|
|||
|
||||
describe "role_properties()" do
|
||||
before do
|
||||
dsl.role :redis, %w[example1.com example2.com], :redis => { :port => 6379, :type => :slave }
|
||||
dsl.server "example1.com", :roles => %w{web}, :active => true, :web => { :port => 80 }
|
||||
dsl.server "example2.com", :roles => %w{web redis}, :web => { :port => 81 }, :redis => { :type => :master }
|
||||
dsl.server "example3.com", :roles => %w{app}, :primary => true
|
||||
dsl.role :redis, %w[example1.com example2.com], redis: { port: 6379, type: :slave }
|
||||
dsl.server "example1.com", roles: %w{web}, active: true, web: { port: 80 }
|
||||
dsl.server "example2.com", roles: %w{web redis}, web: { port: 81 }, redis: { type: :master }
|
||||
dsl.server "example3.com", roles: %w{app}, primary: true
|
||||
end
|
||||
|
||||
it "retrieves properties for a single role as a set" do
|
||||
rps = dsl.role_properties(:app)
|
||||
expect(rps).to eq(Set[{ :hostname => "example3.com", :role => :app }])
|
||||
expect(rps).to eq(Set[{ hostname: "example3.com", role: :app }])
|
||||
end
|
||||
|
||||
it "retrieves properties for multiple roles as a set" do
|
||||
rps = dsl.role_properties(:app, :web)
|
||||
expect(rps).to eq(Set[{ :hostname => "example3.com", :role => :app }, { :hostname => "example1.com", :role => :web, :port => 80 }, { :hostname => "example2.com", :role => :web, :port => 81 }])
|
||||
expect(rps).to eq(Set[{ hostname: "example3.com", role: :app }, { hostname: "example1.com", role: :web, port: 80 }, { hostname: "example2.com", role: :web, port: 81 }])
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -599,8 +599,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)
|
||||
|
@ -609,10 +609,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
|
||||
|
@ -620,9 +620,9 @@ 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)
|
||||
dsl.role_properties(:redis, :web, :select => :active) do |host, role, props|
|
||||
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
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ module Capistrano
|
|||
class Configuration
|
||||
describe Question do
|
||||
let(:question) { Question.new(key, default, options) }
|
||||
let(:question_without_echo) { Question.new(key, default, :echo => false) }
|
||||
let(:question_without_echo) { Question.new(key, default, echo: false) }
|
||||
let(:default) { :default }
|
||||
let(:key) { :branch }
|
||||
let(:options) { nil }
|
||||
|
|
|
@ -79,7 +79,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
context "properties contains roles" do
|
||||
let(:properties) { { :roles => [:clouds] } }
|
||||
let(:properties) { { roles: [:clouds] } }
|
||||
|
||||
it "adds the roles" do
|
||||
expect(server.roles.first).to eq :clouds
|
||||
|
@ -87,7 +87,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
context "properties contains user" do
|
||||
let(:properties) { { :user => "tomc" } }
|
||||
let(:properties) { { user: "tomc" } }
|
||||
|
||||
it "sets the user" do
|
||||
expect(server.user).to eq "tomc"
|
||||
|
@ -99,7 +99,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
context "properties contains port" do
|
||||
let(:properties) { { :port => 2222 } }
|
||||
let(:properties) { { port: 2222 } }
|
||||
|
||||
it "sets the port" do
|
||||
expect(server.port).to eq 2222
|
||||
|
@ -107,7 +107,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
context "properties contains key" do
|
||||
let(:properties) { { :key => "/key" } }
|
||||
let(:properties) { { key: "/key" } }
|
||||
|
||||
it "adds the key" do
|
||||
expect(server.keys).to include "/key"
|
||||
|
@ -115,7 +115,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
context "properties contains password" do
|
||||
let(:properties) { { :password => "supersecret" } }
|
||||
let(:properties) { { password: "supersecret" } }
|
||||
|
||||
it "adds the key" do
|
||||
expect(server.password).to eq "supersecret"
|
||||
|
@ -123,7 +123,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
context "new properties" do
|
||||
let(:properties) { { :webscales => 5 } }
|
||||
let(:properties) { { webscales: 5 } }
|
||||
|
||||
it "adds the properties" do
|
||||
expect(server.properties.webscales).to eq 5
|
||||
|
@ -131,7 +131,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
context "existing properties" do
|
||||
let(:properties) { { :webscales => 6 } }
|
||||
let(:properties) { { webscales: 6 } }
|
||||
|
||||
it "keeps the existing properties" do
|
||||
expect(server.properties.webscales).to eq 6
|
||||
|
@ -157,46 +157,46 @@ module Capistrano
|
|||
context "value is a symbol" do
|
||||
context "value matches server property" do
|
||||
context "with :filter" do
|
||||
let(:options) { { :filter => :active } }
|
||||
let(:options) { { filter: :active } }
|
||||
it { expect(subject).to be_truthy }
|
||||
end
|
||||
|
||||
context "with :select" do
|
||||
let(:options) { { :select => :active } }
|
||||
let(:options) { { select: :active } }
|
||||
it { expect(subject).to be_truthy }
|
||||
end
|
||||
|
||||
context "with :exclude" do
|
||||
let(:options) { { :exclude => :active } }
|
||||
let(:options) { { exclude: :active } }
|
||||
it { expect(subject).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
context "value does not match server properly" do
|
||||
context "with :active true" do
|
||||
let(:options) { { :active => true } }
|
||||
let(:options) { { active: true } }
|
||||
it { expect(subject).to be_truthy }
|
||||
end
|
||||
|
||||
context "with :active false" do
|
||||
let(:options) { { :active => false } }
|
||||
let(:options) { { active: false } }
|
||||
it { expect(subject).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
context "value does not match server properly" do
|
||||
context "with :filter" do
|
||||
let(:options) { { :filter => :inactive } }
|
||||
let(:options) { { filter: :inactive } }
|
||||
it { expect(subject).to be_falsey }
|
||||
end
|
||||
|
||||
context "with :select" do
|
||||
let(:options) { { :select => :inactive } }
|
||||
let(:options) { { select: :inactive } }
|
||||
it { expect(subject).to be_falsey }
|
||||
end
|
||||
|
||||
context "with :exclude" do
|
||||
let(:options) { { :exclude => :inactive } }
|
||||
let(:options) { { exclude: :inactive } }
|
||||
it { expect(subject).to be_truthy }
|
||||
end
|
||||
end
|
||||
|
@ -204,12 +204,12 @@ module Capistrano
|
|||
|
||||
context "key is a property" do
|
||||
context "with :active true" do
|
||||
let(:options) { { :active => true } }
|
||||
let(:options) { { active: true } }
|
||||
it { expect(subject).to be_truthy }
|
||||
end
|
||||
|
||||
context "with :active false" do
|
||||
let(:options) { { :active => false } }
|
||||
let(:options) { { active: false } }
|
||||
it { expect(subject).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
@ -217,34 +217,34 @@ module Capistrano
|
|||
context "value is a proc" do
|
||||
context "value matches server property" do
|
||||
context "with :filter" do
|
||||
let(:options) { { :filter => ->(s) { s.properties.active } } }
|
||||
let(:options) { { filter: ->(s) { s.properties.active } } }
|
||||
it { expect(subject).to be_truthy }
|
||||
end
|
||||
|
||||
context "with :select" do
|
||||
let(:options) { { :select => ->(s) { s.properties.active } } }
|
||||
let(:options) { { select: ->(s) { s.properties.active } } }
|
||||
it { expect(subject).to be_truthy }
|
||||
end
|
||||
|
||||
context "with :exclude" do
|
||||
let(:options) { { :exclude => ->(s) { s.properties.active } } }
|
||||
let(:options) { { exclude: ->(s) { s.properties.active } } }
|
||||
it { expect(subject).to be_falsey }
|
||||
end
|
||||
end
|
||||
|
||||
context "value does not match server properly" do
|
||||
context "with :filter" do
|
||||
let(:options) { { :filter => ->(s) { s.properties.inactive } } }
|
||||
let(:options) { { filter: ->(s) { s.properties.inactive } } }
|
||||
it { expect(subject).to be_falsey }
|
||||
end
|
||||
|
||||
context "with :select" do
|
||||
let(:options) { { :select => ->(s) { s.properties.inactive } } }
|
||||
let(:options) { { select: ->(s) { s.properties.inactive } } }
|
||||
it { expect(subject).to be_falsey }
|
||||
end
|
||||
|
||||
context "with :exclude" do
|
||||
let(:options) { { :exclude => ->(s) { s.properties.inactive } } }
|
||||
let(:options) { { exclude: ->(s) { s.properties.inactive } } }
|
||||
it { expect(subject).to be_truthy }
|
||||
end
|
||||
end
|
||||
|
@ -265,11 +265,11 @@ module Capistrano
|
|||
|
||||
context "custom" do
|
||||
let(:properties) do
|
||||
{ :ssh_options => {
|
||||
:user => "another_user",
|
||||
:keys => %w(/home/another_user/.ssh/id_rsa),
|
||||
:forward_agent => false,
|
||||
:auth_methods => %w(publickey password) } }
|
||||
{ ssh_options: {
|
||||
user: "another_user",
|
||||
keys: %w(/home/another_user/.ssh/id_rsa),
|
||||
forward_agent: false,
|
||||
auth_methods: %w(publickey password) } }
|
||||
end
|
||||
|
||||
before do
|
||||
|
|
|
@ -18,8 +18,8 @@ module Capistrano
|
|||
end
|
||||
|
||||
it "handles de-duplification within roles with users" do
|
||||
servers.add_role(:app, %w{1}, :user => "nick")
|
||||
servers.add_role(:app, %w{1}, :user => "fred")
|
||||
servers.add_role(:app, %w{1}, user: "nick")
|
||||
servers.add_role(:app, %w{1}, user: "fred")
|
||||
expect(servers.count).to eq 1
|
||||
end
|
||||
|
||||
|
@ -34,12 +34,12 @@ module Capistrano
|
|||
end
|
||||
|
||||
it "creates distinct server properties" do
|
||||
servers.add_role(:db, %w{1 2}, :db => { :port => 1234 })
|
||||
servers.add_host("1", :db => { :master => true })
|
||||
servers.add_role(:db, %w{1 2}, db: { port: 1234 })
|
||||
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
|
||||
|
||||
|
@ -81,14 +81,14 @@ module Capistrano
|
|||
|
||||
it "takes the first server with the primary have the primary flag" do
|
||||
servers.add_role(:app, %w{1 2})
|
||||
servers.add_host("2", :primary => true)
|
||||
servers.add_host("2", primary: true)
|
||||
expect(servers.fetch_primary(:app).hostname).to eq("2")
|
||||
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)
|
||||
servers.add_host("2", primary: true)
|
||||
expect(servers.fetch_primary(:app).hostname).to eq("2")
|
||||
end
|
||||
end
|
||||
|
@ -118,7 +118,7 @@ module Capistrano
|
|||
|
||||
describe "adding a server" do
|
||||
before do
|
||||
servers.add_host("1", :roles => [:app, "web"], :test => :value)
|
||||
servers.add_host("1", roles: [:app, "web"], test: :value)
|
||||
end
|
||||
|
||||
it "can create a server with properties" do
|
||||
|
@ -129,72 +129,72 @@ module Capistrano
|
|||
end
|
||||
|
||||
it "can accept multiple servers with the same hostname but different ports or users" do
|
||||
servers.add_host("1", :roles => [:app, "web"], :test => :value, :port => 12)
|
||||
servers.add_host("1", :roles => [:app, "web"], :test => :value, :port => 34)
|
||||
servers.add_host("1", :roles => [:app, "web"], :test => :value, :user => "root")
|
||||
servers.add_host("1", :roles => [:app, "web"], :test => :value, :user => "deployer")
|
||||
servers.add_host("1", :roles => [:app, "web"], :test => :value, :user => "root", :port => 34)
|
||||
servers.add_host("1", :roles => [:app, "web"], :test => :value, :user => "deployer", :port => 34)
|
||||
servers.add_host("1", :roles => [:app, "web"], :test => :value, :user => "deployer", :port => 56)
|
||||
servers.add_host("1", roles: [:app, "web"], test: :value, port: 12)
|
||||
servers.add_host("1", roles: [:app, "web"], test: :value, port: 34)
|
||||
servers.add_host("1", roles: [:app, "web"], test: :value, user: "root")
|
||||
servers.add_host("1", roles: [:app, "web"], test: :value, user: "deployer")
|
||||
servers.add_host("1", roles: [:app, "web"], test: :value, user: "root", port: 34)
|
||||
servers.add_host("1", roles: [:app, "web"], test: :value, user: "deployer", port: 34)
|
||||
servers.add_host("1", roles: [:app, "web"], test: :value, user: "deployer", port: 56)
|
||||
expect(servers.count).to eq(5)
|
||||
end
|
||||
|
||||
describe "with a :user property" do
|
||||
it "sets the server ssh username" do
|
||||
servers.add_host("1", :roles => [:app, "web"], :user => "nick")
|
||||
servers.add_host("1", roles: [:app, "web"], user: "nick")
|
||||
expect(servers.count).to eq(1)
|
||||
expect(servers.roles_for([:all]).first.user).to eq "nick"
|
||||
end
|
||||
|
||||
it "overwrites the value of a user specified in the hostname" do
|
||||
servers.add_host("brian@1", :roles => [:app, "web"], :user => "nick")
|
||||
servers.add_host("brian@1", roles: [:app, "web"], user: "nick")
|
||||
expect(servers.count).to eq(1)
|
||||
expect(servers.roles_for([:all]).first.user).to eq "nick"
|
||||
end
|
||||
end
|
||||
|
||||
it "overwrites the value of a previously defined scalar property" do
|
||||
servers.add_host("1", :roles => [:app, "web"], :test => :volatile)
|
||||
servers.add_host("1", roles: [:app, "web"], test: :volatile)
|
||||
expect(servers.count).to eq(1)
|
||||
expect(servers.roles_for([:all]).first.properties.test).to eq :volatile
|
||||
end
|
||||
|
||||
it "merges previously defined hash properties" do
|
||||
servers.add_host("1", :roles => [:b], :db => { :port => 1234 })
|
||||
servers.add_host("1", :roles => [:b], :db => { :master => true })
|
||||
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
|
||||
servers.add_host("1", :roles => [:b], :steps => [1, 3, 5])
|
||||
servers.add_host("1", :roles => [:b], :steps => [1, 9])
|
||||
servers.add_host("1", roles: [:b], steps: [1, 3, 5])
|
||||
servers.add_host("1", roles: [:b], steps: [1, 9])
|
||||
expect(servers.count).to eq(1)
|
||||
expect(servers.roles_for([:b]).first.properties.steps).to eq([1, 3, 5, 1, 9])
|
||||
end
|
||||
|
||||
it "merges previously defined set properties" do
|
||||
servers.add_host("1", :roles => [:b], :endpoints => Set[123, 333])
|
||||
servers.add_host("1", :roles => [:b], :endpoints => Set[222, 333])
|
||||
servers.add_host("1", roles: [:b], endpoints: Set[123, 333])
|
||||
servers.add_host("1", roles: [:b], endpoints: Set[222, 333])
|
||||
expect(servers.count).to eq(1)
|
||||
expect(servers.roles_for([:b]).first.properties.endpoints).to eq(Set[123, 222, 333])
|
||||
end
|
||||
|
||||
it "adds array property value only ones for a new host" do
|
||||
servers.add_host("2", :roles => [:array_test], :array_property => [1, 2])
|
||||
servers.add_host("2", roles: [:array_test], array_property: [1, 2])
|
||||
expect(servers.roles_for([:array_test]).first.properties.array_property).to eq [1, 2]
|
||||
end
|
||||
|
||||
it "updates roles when custom user defined" do
|
||||
servers.add_host("1", :roles => ["foo"], :user => "custom")
|
||||
servers.add_host("1", :roles => ["bar"], :user => "custom")
|
||||
servers.add_host("1", roles: ["foo"], user: "custom")
|
||||
servers.add_host("1", roles: ["bar"], user: "custom")
|
||||
expect(servers.roles_for([:foo]).first.hostname).to eq "1"
|
||||
expect(servers.roles_for([:bar]).first.hostname).to eq "1"
|
||||
end
|
||||
|
||||
it "updates roles when custom port defined" do
|
||||
servers.add_host("1", :roles => ["foo"], :port => 1234)
|
||||
servers.add_host("1", :roles => ["bar"], :port => 1234)
|
||||
servers.add_host("1", roles: ["foo"], port: 1234)
|
||||
servers.add_host("1", roles: ["bar"], port: 1234)
|
||||
expect(servers.roles_for([:foo]).first.hostname).to eq "1"
|
||||
expect(servers.roles_for([:bar]).first.hostname).to eq "1"
|
||||
end
|
||||
|
@ -202,69 +202,69 @@ module Capistrano
|
|||
|
||||
describe "selecting roles" do
|
||||
before do
|
||||
servers.add_host("1", :roles => :app, :active => true)
|
||||
servers.add_host("2", :roles => :app)
|
||||
servers.add_host("1", roles: :app, active: true)
|
||||
servers.add_host("2", roles: :app)
|
||||
end
|
||||
|
||||
it "is empty if the filter would remove all matching hosts" do
|
||||
expect(servers.roles_for([:app, :select => :inactive])).to be_empty
|
||||
expect(servers.roles_for([:app, select: :inactive])).to be_empty
|
||||
end
|
||||
|
||||
it "can filter hosts by properties on the host object using symbol as shorthand" do
|
||||
expect(servers.roles_for([:app, :filter => :active]).length).to eq 1
|
||||
expect(servers.roles_for([:app, filter: :active]).length).to eq 1
|
||||
end
|
||||
|
||||
it "can select hosts by properties on the host object using symbol as shorthand" do
|
||||
expect(servers.roles_for([:app, :select => :active]).length).to eq 1
|
||||
expect(servers.roles_for([:app, select: :active]).length).to eq 1
|
||||
end
|
||||
|
||||
it "can filter hosts by properties on the host using a regular proc" do
|
||||
expect(servers.roles_for([:app, :filter => ->(h) { h.properties.active }]).length).to eq 1
|
||||
expect(servers.roles_for([:app, filter: ->(h) { h.properties.active }]).length).to eq 1
|
||||
end
|
||||
|
||||
it "can select hosts by properties on the host using a regular proc" do
|
||||
expect(servers.roles_for([:app, :select => ->(h) { h.properties.active }]).length).to eq 1
|
||||
expect(servers.roles_for([:app, select: ->(h) { h.properties.active }]).length).to eq 1
|
||||
end
|
||||
|
||||
it "is empty if the regular proc filter would remove all matching hosts" do
|
||||
expect(servers.roles_for([:app, :select => ->(h) { h.properties.inactive }])).to be_empty
|
||||
expect(servers.roles_for([:app, select: ->(h) { h.properties.inactive }])).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "excluding by property" do
|
||||
before do
|
||||
servers.add_host("1", :roles => :app, :active => true)
|
||||
servers.add_host("2", :roles => :app, :active => true, :no_release => true)
|
||||
servers.add_host("1", roles: :app, active: true)
|
||||
servers.add_host("2", roles: :app, active: true, no_release: true)
|
||||
end
|
||||
|
||||
it "is empty if the filter would remove all matching hosts" do
|
||||
hosts = servers.roles_for([:app, :exclude => :active])
|
||||
hosts = servers.roles_for([:app, exclude: :active])
|
||||
expect(hosts.map(&:hostname)).to be_empty
|
||||
end
|
||||
|
||||
it "returns the servers without the attributes specified" do
|
||||
hosts = servers.roles_for([:app, :exclude => :no_release])
|
||||
hosts = servers.roles_for([:app, exclude: :no_release])
|
||||
expect(hosts.map(&:hostname)).to eq %w{1}
|
||||
end
|
||||
|
||||
it "can exclude hosts by properties on the host using a regular proc" do
|
||||
hosts = servers.roles_for([:app, :exclude => ->(h) { h.properties.no_release }])
|
||||
hosts = servers.roles_for([:app, exclude: ->(h) { h.properties.no_release }])
|
||||
expect(hosts.map(&:hostname)).to eq %w{1}
|
||||
end
|
||||
|
||||
it "is empty if the regular proc filter would remove all matching hosts" do
|
||||
hosts = servers.roles_for([:app, :exclude => ->(h) { h.properties.active }])
|
||||
hosts = servers.roles_for([:app, exclude: ->(h) { h.properties.active }])
|
||||
expect(hosts.map(&:hostname)).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "filtering roles internally" do
|
||||
before do
|
||||
servers.add_host("1", :roles => :app, :active => true)
|
||||
servers.add_host("2", :roles => :app)
|
||||
servers.add_host("3", :roles => :web)
|
||||
servers.add_host("4", :roles => :web)
|
||||
servers.add_host("5", :roles => :db)
|
||||
servers.add_host("1", roles: :app, active: true)
|
||||
servers.add_host("2", roles: :app)
|
||||
servers.add_host("3", roles: :web)
|
||||
servers.add_host("4", roles: :web)
|
||||
servers.add_host("5", roles: :db)
|
||||
end
|
||||
|
||||
subject { servers.roles_for(roles).map(&:hostname) }
|
||||
|
|
|
@ -7,7 +7,7 @@ module Capistrano
|
|||
|
||||
describe ".new" do
|
||||
it "accepts initial hash" do
|
||||
configuration = described_class.new(:custom => "value")
|
||||
configuration = described_class.new(custom: "value")
|
||||
expect(configuration.fetch(:custom)).to eq("value")
|
||||
end
|
||||
end
|
||||
|
@ -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"
|
||||
SSHKit::Backend::Netssh.configure { |ssh| ssh.ssh_options = { :password => "einstein" } }
|
||||
config.set :ssh_options, user: "albert"
|
||||
SSHKit::Backend::Netssh.configure { |ssh| ssh.ssh_options = { password: "einstein" } }
|
||||
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,11 +11,11 @@ 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
|
||||
dsl.t(:phrase, :count => 2)
|
||||
dsl.t(:phrase, count: 2)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ module Capistrano
|
|||
end
|
||||
|
||||
it "skips registering hooks if :hooks => false" do
|
||||
DummyPlugin.new(:hooks => false)
|
||||
DummyPlugin.new(hooks: false)
|
||||
expect(Rake::Task["deploy:published"].prerequisites).to be_empty
|
||||
end
|
||||
|
||||
|
|
8
spec/support/Vagrantfile
vendored
8
spec/support/Vagrantfile
vendored
|
@ -4,16 +4,16 @@ Vagrant.configure("2") do |config|
|
|||
config.ssh.insert_key = false
|
||||
|
||||
[:app].each_with_index do |role, i|
|
||||
config.vm.define(role, :primary => true) do |primary|
|
||||
config.vm.define(role, primary: true) do |primary|
|
||||
primary.vm.define role
|
||||
primary.vm.box = "hashicorp/precise64"
|
||||
primary.vm.network "forwarded_port", :guest => 22, :host => "222#{i}".to_i
|
||||
primary.vm.provision :shell, :inline => "sudo apt-get -y install git-core"
|
||||
primary.vm.network "forwarded_port", guest: 22, host: "222#{i}".to_i
|
||||
primary.vm.provision :shell, inline: "sudo apt-get -y install git-core"
|
||||
|
||||
vagrantkey = open("https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub", "r", &:read)
|
||||
|
||||
primary.vm.provision :shell,
|
||||
:inline => <<-INLINE
|
||||
inline: <<-INLINE
|
||||
install -d -m 700 /root/.ssh
|
||||
echo -e "#{vagrantkey}" > /root/.ssh/authorized_keys
|
||||
chmod 0600 /root/.ssh/authorized_keys
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace :deploy do
|
||||
namespace :check do
|
||||
task :linked_files => "config/database.yml"
|
||||
task linked_files: "config/database.yml"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue