mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Fix to force hash-rockets
This commit is contained in:
parent
f357fb4ea7
commit
d9a7b23257
22 changed files with 213 additions and 213 deletions
|
@ -44,7 +44,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
def question
|
def question
|
||||||
I18n.t(:question, key: key, default_value: default, scope: :capistrano)
|
I18n.t(:question, :key => key, :default_value => default, :scope => :capistrano)
|
||||||
end
|
end
|
||||||
|
|
||||||
def echo?
|
def echo?
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_role(role, hosts, options={})
|
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)) }
|
Array(hosts).each { |host| add_host(host, Marshal.load(options_deepcopy)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ module Capistrano
|
||||||
if block_given?
|
if block_given?
|
||||||
yield host, role, props
|
yield host, role, props
|
||||||
else
|
else
|
||||||
rps << (props || {}).merge( role: role, hostname: host.hostname )
|
rps << (props || {}).merge( :role => role, :hostname => host.hostname )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
def t(key, options={})
|
def t(key, options={})
|
||||||
I18n.t(key, options.merge(scope: :capistrano))
|
I18n.t(key, options.merge(:scope => :capistrano))
|
||||||
end
|
end
|
||||||
|
|
||||||
def scm
|
def scm
|
||||||
|
@ -30,15 +30,15 @@ module Capistrano
|
||||||
def revision_log_message
|
def revision_log_message
|
||||||
fetch(:revision_log_message,
|
fetch(:revision_log_message,
|
||||||
t(:revision_log_message,
|
t(:revision_log_message,
|
||||||
branch: fetch(:branch),
|
:branch => fetch(:branch),
|
||||||
user: local_user,
|
:user => local_user,
|
||||||
sha: fetch(:current_revision),
|
:sha => fetch(:current_revision),
|
||||||
release: fetch(:release_timestamp))
|
:release => fetch(:release_timestamp))
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def rollback_log_message
|
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
|
end
|
||||||
|
|
||||||
def local_user
|
def local_user
|
||||||
|
|
|
@ -28,7 +28,7 @@ module Capistrano
|
||||||
if names.last.is_a? Hash
|
if names.last.is_a? Hash
|
||||||
names.last.merge!({ :exclude => :no_release })
|
names.last.merge!({ :exclude => :no_release })
|
||||||
else
|
else
|
||||||
names << { exclude: :no_release }
|
names << { :exclude => :no_release }
|
||||||
end
|
end
|
||||||
roles(*names)
|
roles(*names)
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,7 +53,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
def exit_deploy_because_of_exception(ex)
|
def exit_deploy_because_of_exception(ex)
|
||||||
warn t(:deploy_failed, ex: ex.message)
|
warn t(:deploy_failed, :ex => ex.message)
|
||||||
invoke 'deploy:failed'
|
invoke 'deploy:failed'
|
||||||
exit(false)
|
exit(false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,37 +1,37 @@
|
||||||
require 'i18n'
|
require 'i18n'
|
||||||
|
|
||||||
en = {
|
en = {
|
||||||
starting: 'Starting',
|
:starting => 'Starting',
|
||||||
capified: 'Capified',
|
:capified => 'Capified',
|
||||||
start: 'Start',
|
:start => 'Start',
|
||||||
update: 'Update',
|
:update => 'Update',
|
||||||
finalize: 'Finalise',
|
:finalize => 'Finalise',
|
||||||
finishing: 'Finishing',
|
:finishing => 'Finishing',
|
||||||
finished: 'Finished',
|
:finished => 'Finished',
|
||||||
stage_not_set: 'Stage not set, please call something such as `cap production deploy`, where production is a stage you have defined.',
|
: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}',
|
:written_file => 'create %{file}',
|
||||||
question: 'Please enter %{key} (%{default_value}): ',
|
:question => 'Please enter %{key} (%{default_value}): ',
|
||||||
keeping_releases: 'Keeping %{keep_releases} of %{releases} deployed releases on %{host}',
|
:keeping_releases => 'Keeping %{keep_releases} of %{releases} deployed releases on %{host}',
|
||||||
no_old_releases: 'No old releases (keeping newest %{keep_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}',
|
:linked_file_does_not_exist => 'linked file %{file} does not exist on %{host}',
|
||||||
cannot_rollback: 'There are no older releases to rollback to',
|
:cannot_rollback => 'There are no older releases to rollback to',
|
||||||
mirror_exists: 'The repository mirror is at %{at}',
|
:mirror_exists => 'The repository mirror is at %{at}',
|
||||||
revision_log_message: 'Branch %{branch} (at %{sha}) deployed as release %{release} by %{user}',
|
:revision_log_message => 'Branch %{branch} (at %{sha}) deployed as release %{release} by %{user}',
|
||||||
rollback_log_message: '%{user} rolled back to release %{release}',
|
:rollback_log_message => '%{user} rolled back to release %{release}',
|
||||||
deploy_failed: 'The deploy has failed with an error: %{ex}',
|
:deploy_failed => 'The deploy has failed with an error: %{ex}',
|
||||||
console: {
|
:console => {
|
||||||
welcome: 'capistrano console - enter command to execute on %{stage}',
|
:welcome => 'capistrano console - enter command to execute on %{stage}',
|
||||||
bye: 'bye'
|
:bye => 'bye'
|
||||||
},
|
},
|
||||||
error: {
|
:error => {
|
||||||
user: {
|
:user => {
|
||||||
does_not_exist: 'User %{user} does not exists',
|
:does_not_exist => 'User %{user} does not exists',
|
||||||
cannot_switch: 'Cannot switch to user %{user}'
|
: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=)
|
if I18n.respond_to?(:enforce_available_locales=)
|
||||||
I18n.enforce_available_locales = true
|
I18n.enforce_available_locales = true
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Capistrano::Plugin < Rake::TaskLib
|
||||||
# skipped, if you want full control over when and how the plugin's tasks are
|
# skipped, if you want full control over when and how the plugin's tasks are
|
||||||
# executed. Simply pass `hooks:false` to opt out.
|
# executed. Simply pass `hooks:false` to opt out.
|
||||||
#
|
#
|
||||||
def initialize(hooks:true)
|
def initialize(hooks: true)
|
||||||
define_tasks
|
define_tasks
|
||||||
register_hooks if hooks
|
register_hooks if hooks
|
||||||
task "load:defaults" do
|
task "load:defaults" do
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
desc 'Execute remote commands'
|
desc 'Execute remote commands'
|
||||||
task :console do
|
task :console do
|
||||||
stage = fetch(:stage)
|
stage = fetch(:stage)
|
||||||
puts I18n.t('console.welcome', scope: :capistrano, stage: stage)
|
puts I18n.t('console.welcome', :scope => :capistrano, :stage => stage)
|
||||||
loop do
|
loop do
|
||||||
print "#{stage}> "
|
print "#{stage}> "
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace :deploy do
|
||||||
on release_roles :all do |host|
|
on release_roles :all do |host|
|
||||||
linked_files(shared_path).each do |file|
|
linked_files(shared_path).each do |file|
|
||||||
unless test "[ -f #{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
|
exit 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -160,7 +160,7 @@ namespace :deploy do
|
||||||
on release_roles :all do |host|
|
on release_roles :all do |host|
|
||||||
releases = capture(:ls, '-xtr', releases_path).split
|
releases = capture(:ls, '-xtr', releases_path).split
|
||||||
if releases.count >= fetch(:keep_releases)
|
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)))
|
directories = (releases - releases.last(fetch(:keep_releases)))
|
||||||
if directories.any?
|
if directories.any?
|
||||||
directories_str = directories.map do |release|
|
directories_str = directories.map do |release|
|
||||||
|
@ -168,7 +168,7 @@ namespace :deploy do
|
||||||
end.join(" ")
|
end.join(" ")
|
||||||
execute :rm, '-rf', directories_str
|
execute :rm, '-rf', directories_str
|
||||||
else
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,4 +65,4 @@ task :deploy do
|
||||||
invoke "deploy:#{task}"
|
invoke "deploy:#{task}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
task default: :deploy
|
task :default => :deploy
|
||||||
|
|
|
@ -6,8 +6,8 @@ namespace :git do
|
||||||
|
|
||||||
set :git_environmental_variables, ->() {
|
set :git_environmental_variables, ->() {
|
||||||
{
|
{
|
||||||
git_askpass: "/bin/echo",
|
:git_askpass => "/bin/echo",
|
||||||
git_ssh: "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
|
:git_ssh => "#{fetch(:tmp_dir)}/#{fetch(:application)}/git-ssh.sh"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ namespace :git do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Check that the repository is reachable'
|
desc 'Check that the repository is reachable'
|
||||||
task check: :'git:wrapper' do
|
task :check => :'git:wrapper' do
|
||||||
fetch(:branch)
|
fetch(:branch)
|
||||||
on release_roles :all do
|
on release_roles :all do
|
||||||
with fetch(:git_environmental_variables) do
|
with fetch(:git_environmental_variables) do
|
||||||
|
@ -31,10 +31,10 @@ namespace :git do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Clone the repo to the cache'
|
desc 'Clone the repo to the cache'
|
||||||
task clone: :'git:wrapper' do
|
task :clone => :'git:wrapper' do
|
||||||
on release_roles :all do
|
on release_roles :all do
|
||||||
if strategy.test
|
if strategy.test
|
||||||
info t(:mirror_exists, at: repo_path)
|
info t(:mirror_exists, :at => repo_path)
|
||||||
else
|
else
|
||||||
within deploy_path do
|
within deploy_path do
|
||||||
with fetch(:git_environmental_variables) do
|
with fetch(:git_environmental_variables) do
|
||||||
|
@ -46,7 +46,7 @@ namespace :git do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Update the repo mirror to reflect the origin state'
|
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
|
on release_roles :all do
|
||||||
within repo_path do
|
within repo_path do
|
||||||
with fetch(:git_environmental_variables) do
|
with fetch(:git_environmental_variables) do
|
||||||
|
@ -57,7 +57,7 @@ namespace :git do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Copy repo to releases'
|
desc 'Copy repo to releases'
|
||||||
task create_release: :'git:update' do
|
task :create_release => :'git:update' do
|
||||||
on release_roles :all do
|
on release_roles :all do
|
||||||
with fetch(:git_environmental_variables) do
|
with fetch(:git_environmental_variables) do
|
||||||
within repo_path do
|
within repo_path do
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace :hg do
|
||||||
task :clone do
|
task :clone do
|
||||||
on release_roles :all do
|
on release_roles :all do
|
||||||
if strategy.test
|
if strategy.test
|
||||||
info t(:mirror_exists, at: repo_path)
|
info t(:mirror_exists, :at => repo_path)
|
||||||
else
|
else
|
||||||
within deploy_path do
|
within deploy_path do
|
||||||
strategy.clone
|
strategy.clone
|
||||||
|
|
|
@ -14,8 +14,8 @@ task :install do
|
||||||
|
|
||||||
mkdir_p deploy_dir
|
mkdir_p deploy_dir
|
||||||
|
|
||||||
entries = [{template: deploy_rb, file: config_dir.join('deploy.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 += envs.split(',').map { |stage| {:template => stage_rb, :file => deploy_dir.join("#{stage}.rb")} }
|
||||||
|
|
||||||
entries.each do |entry|
|
entries.each do |entry|
|
||||||
if File.exist?(entry[:file])
|
if File.exist?(entry[:file])
|
||||||
|
@ -23,7 +23,7 @@ task :install do
|
||||||
else
|
else
|
||||||
File.open(entry[:file], 'w+') do |f|
|
File.open(entry[:file], 'w+') do |f|
|
||||||
f.write(ERB.new(File.read(entry[:template])).result(binding))
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -34,9 +34,9 @@ task :install do
|
||||||
warn "[skip] Capfile already exists"
|
warn "[skip] Capfile already exists"
|
||||||
else
|
else
|
||||||
FileUtils.cp(capfile, 'Capfile')
|
FileUtils.cp(capfile, 'Capfile')
|
||||||
puts I18n.t(:written_file, scope: :capistrano, file: 'Capfile')
|
puts I18n.t(:written_file, :scope => :capistrano, :file => 'Capfile')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
puts I18n.t :capified, scope: :capistrano
|
puts I18n.t :capified, :scope => :capistrano
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace :svn do
|
||||||
task :clone do
|
task :clone do
|
||||||
on release_roles :all do
|
on release_roles :all do
|
||||||
if strategy.test
|
if strategy.test
|
||||||
info t(:mirror_exists, at: repo_path)
|
info t(:mirror_exists, :at => repo_path)
|
||||||
else
|
else
|
||||||
within deploy_path do
|
within deploy_path do
|
||||||
strategy.clone
|
strategy.clone
|
||||||
|
|
|
@ -11,11 +11,11 @@ describe Capistrano::DSL do
|
||||||
describe 'setting and fetching hosts' do
|
describe 'setting and fetching hosts' do
|
||||||
describe 'when defining a host using the `server` syntax' do
|
describe 'when defining a host using the `server` syntax' do
|
||||||
before do
|
before do
|
||||||
dsl.server 'example1.com', roles: %w{web}, active: true
|
dsl.server 'example1.com', :roles => %w{web}, :active => true
|
||||||
dsl.server 'example2.com', roles: %w{web}
|
dsl.server 'example2.com', :roles => %w{web}
|
||||||
dsl.server 'example3.com', roles: %w{app web}, active: true
|
dsl.server 'example3.com', :roles => %w{app web}, :active => true
|
||||||
dsl.server 'example4.com', roles: %w{app}, primary: true
|
dsl.server 'example4.com', :roles => %w{app}, :primary => true
|
||||||
dsl.server 'example5.com', roles: %w{db}, no_release: true, active:true
|
dsl.server 'example5.com', :roles => %w{db}, :no_release => true, :active => true
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'fetching all servers' do
|
describe 'fetching all servers' do
|
||||||
|
@ -37,7 +37,7 @@ describe Capistrano::DSL do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with property filter options' do
|
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
|
it 'returns all release servers that match the property filter' do
|
||||||
expect(subject.map(&:hostname)).to eq %w{example1.com example3.com}
|
expect(subject.map(&:hostname)).to eq %w{example1.com example3.com}
|
||||||
|
@ -48,7 +48,7 @@ describe Capistrano::DSL do
|
||||||
describe 'fetching servers by multiple roles' do
|
describe 'fetching servers by multiple roles' do
|
||||||
it "does not confuse the last role with options" 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).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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ describe Capistrano::DSL do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'fetching filtered servers by role' do
|
describe 'fetching filtered servers by role' do
|
||||||
subject { dsl.roles(:app, filter: :active) }
|
subject { dsl.roles(:app, :filter => :active) }
|
||||||
|
|
||||||
it 'returns the servers' do
|
it 'returns the servers' do
|
||||||
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
||||||
|
@ -77,7 +77,7 @@ describe Capistrano::DSL do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'fetching selected servers by role' do
|
describe 'fetching selected servers by role' do
|
||||||
subject { dsl.roles(:app, select: :active) }
|
subject { dsl.roles(:app, :select => :active) }
|
||||||
|
|
||||||
it 'returns the servers' do
|
it 'returns the servers' do
|
||||||
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
||||||
|
@ -103,7 +103,7 @@ describe Capistrano::DSL do
|
||||||
describe 'setting an internal host filter' do
|
describe 'setting an internal host filter' do
|
||||||
subject { dsl.roles(:app) }
|
subject { dsl.roles(:app) }
|
||||||
it 'is ignored' do
|
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'])
|
expect(subject.map(&:hostname)).to eq(['example3.com', 'example4.com'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -111,7 +111,7 @@ describe Capistrano::DSL do
|
||||||
describe 'setting an internal role filter' do
|
describe 'setting an internal role filter' do
|
||||||
subject { dsl.roles(:app) }
|
subject { dsl.roles(:app) }
|
||||||
it 'ignores it' do
|
it 'ignores it' do
|
||||||
dsl.set :filter, { role: :web }
|
dsl.set :filter, { :role => :web }
|
||||||
expect(subject.map(&:hostname)).to eq(['example3.com','example4.com'])
|
expect(subject.map(&:hostname)).to eq(['example3.com','example4.com'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -119,7 +119,7 @@ describe Capistrano::DSL do
|
||||||
describe 'setting an internal host and role filter' do
|
describe 'setting an internal host and role filter' do
|
||||||
subject { dsl.roles(:app) }
|
subject { dsl.roles(:app) }
|
||||||
it 'ignores it' do
|
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'])
|
expect(subject.map(&:hostname)).to eq(['example3.com','example4.com'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -127,7 +127,7 @@ describe Capistrano::DSL do
|
||||||
describe 'setting an internal regexp host filter' do
|
describe 'setting an internal regexp host filter' do
|
||||||
subject { dsl.roles(:all) }
|
subject { dsl.roles(:all) }
|
||||||
it 'is ignored' do
|
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})
|
expect(subject.map(&:hostname)).to eq(%w{example1.com example2.com example3.com example4.com example5.com})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -135,7 +135,7 @@ describe Capistrano::DSL do
|
||||||
describe 'setting an internal hosts filter' do
|
describe 'setting an internal hosts filter' do
|
||||||
subject { dsl.roles(:app) }
|
subject { dsl.roles(:app) }
|
||||||
it 'is ignored' do
|
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'])
|
expect(subject.map(&:hostname)).to eq(['example3.com', 'example4.com'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -143,7 +143,7 @@ describe Capistrano::DSL do
|
||||||
describe 'setting an internal roles filter' do
|
describe 'setting an internal roles filter' do
|
||||||
subject { dsl.roles(:app) }
|
subject { dsl.roles(:app) }
|
||||||
it 'ignores it' do
|
it 'ignores it' do
|
||||||
dsl.set :filter, { roles: :web }
|
dsl.set :filter, { :roles => :web }
|
||||||
expect(subject.map(&:hostname)).to eq(['example3.com','example4.com'])
|
expect(subject.map(&:hostname)).to eq(['example3.com','example4.com'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -151,7 +151,7 @@ describe Capistrano::DSL do
|
||||||
describe 'setting an internal hosts and roles filter' do
|
describe 'setting an internal hosts and roles filter' do
|
||||||
subject { dsl.roles(:app) }
|
subject { dsl.roles(:app) }
|
||||||
it 'ignores it' do
|
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'])
|
expect(subject.map(&:hostname)).to eq(['example3.com','example4.com'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -159,7 +159,7 @@ describe Capistrano::DSL do
|
||||||
describe 'setting an internal regexp hosts filter' do
|
describe 'setting an internal regexp hosts filter' do
|
||||||
subject { dsl.roles(:all) }
|
subject { dsl.roles(:all) }
|
||||||
it 'is ignored' do
|
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})
|
expect(subject.map(&:hostname)).to eq(%w{example1.com example2.com example3.com example4.com example5.com})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -177,11 +177,11 @@ describe Capistrano::DSL do
|
||||||
describe 'when defining hosts using the `role` syntax' do
|
describe 'when defining hosts using the `role` syntax' do
|
||||||
before do
|
before do
|
||||||
dsl.role :web, %w{example1.com example2.com example3.com}
|
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 example4.com}
|
||||||
dsl.role :app, %w{example3.com}, active: true
|
dsl.role :app, %w{example3.com}, :active => true
|
||||||
dsl.role :app, %w{example4.com}, primary: true
|
dsl.role :app, %w{example4.com}, :primary => true
|
||||||
dsl.role :db, %w{example5.com}, no_release: true
|
dsl.role :db, %w{example5.com}, :no_release => true
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'fetching all servers' do
|
describe 'fetching all servers' do
|
||||||
|
@ -203,7 +203,7 @@ describe Capistrano::DSL do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with filter options' do
|
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
|
it 'returns all release servers that match the filter' do
|
||||||
expect(subject.map(&:hostname)).to eq %w{example1.com example3.com}
|
expect(subject.map(&:hostname)).to eq %w{example1.com example3.com}
|
||||||
|
@ -229,7 +229,7 @@ describe Capistrano::DSL do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'fetching filtered servers by role' do
|
describe 'fetching filtered servers by role' do
|
||||||
subject { dsl.roles(:app, filter: :active) }
|
subject { dsl.roles(:app, :filter => :active) }
|
||||||
|
|
||||||
it 'returns the servers' do
|
it 'returns the servers' do
|
||||||
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
||||||
|
@ -237,7 +237,7 @@ describe Capistrano::DSL do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'fetching selected servers by role' do
|
describe 'fetching selected servers by role' do
|
||||||
subject { dsl.roles(:app, select: :active) }
|
subject { dsl.roles(:app, :select => :active) }
|
||||||
|
|
||||||
it 'returns the servers' do
|
it 'returns the servers' do
|
||||||
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
expect(subject.map(&:hostname)).to eq %w{example3.com}
|
||||||
|
@ -265,9 +265,9 @@ describe Capistrano::DSL do
|
||||||
describe 'when defining a host using a combination of the `server` and `role` syntax' do
|
describe 'when defining a host using a combination of the `server` and `role` syntax' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
dsl.server 'db@example1.com:1234', roles: %w{db}, 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 'root@example1.com:1234', :roles => %w{web}, :active => true
|
||||||
dsl.server 'example1.com:5678', 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{deployer@example1.com:1234}
|
||||||
dsl.role :app, %w{example1.com:5678}
|
dsl.role :app, %w{example1.com:5678}
|
||||||
end
|
end
|
||||||
|
@ -301,14 +301,14 @@ describe Capistrano::DSL do
|
||||||
|
|
||||||
describe "using the :user property" do
|
describe "using the :user property" do
|
||||||
it "takes precedence over in the host string" 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")
|
expect(subject).to eq("brian@example1.com:1234")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "using the :port property" do
|
describe "using the :port property" do
|
||||||
it "takes precedence over in the host string" 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")
|
expect(subject).to eq("db@example1.com:1234")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -425,7 +425,7 @@ describe Capistrano::DSL do
|
||||||
describe 'configuration SSHKit' do
|
describe 'configuration SSHKit' do
|
||||||
let(:config) { SSHKit.config }
|
let(:config) { SSHKit.config }
|
||||||
let(:backend) { SSHKit.config.backend.config }
|
let(:backend) { SSHKit.config.backend.config }
|
||||||
let(:default_env) { { rails_env: :production } }
|
let(:default_env) { { :rails_env => :production } }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
dsl.set(:format, :dot)
|
dsl.set(:format, :dot)
|
||||||
|
@ -434,9 +434,9 @@ describe Capistrano::DSL do
|
||||||
dsl.set(:pty, true)
|
dsl.set(:pty, true)
|
||||||
dsl.set(:connection_timeout, 10)
|
dsl.set(:connection_timeout, 10)
|
||||||
dsl.set(:ssh_options, {
|
dsl.set(:ssh_options, {
|
||||||
keys: %w(/home/user/.ssh/id_rsa),
|
:keys => %w(/home/user/.ssh/id_rsa),
|
||||||
forward_agent: false,
|
:forward_agent => false,
|
||||||
auth_methods: %w(publickey password)
|
:auth_methods => %w(publickey password)
|
||||||
})
|
})
|
||||||
dsl.configure_backend
|
dsl.configure_backend
|
||||||
end
|
end
|
||||||
|
@ -474,11 +474,11 @@ describe Capistrano::DSL do
|
||||||
describe "when passed server objects" do
|
describe "when passed server objects" do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
dsl.server 'example1.com', roles: %w{web}, active: true
|
dsl.server 'example1.com', :roles => %w{web}, :active => true
|
||||||
dsl.server 'example2.com', roles: %w{web}
|
dsl.server 'example2.com', :roles => %w{web}
|
||||||
dsl.server 'example3.com', roles: %w{app web}, active: true
|
dsl.server 'example3.com', :roles => %w{app web}, :active => true
|
||||||
dsl.server 'example4.com', roles: %w{app}, primary: true
|
dsl.server 'example4.com', :roles => %w{app}, :primary => true
|
||||||
dsl.server 'example5.com', roles: %w{db}, no_release: true
|
dsl.server 'example5.com', :roles => %w{db}, :no_release => true
|
||||||
@coordinator = mock('coordinator')
|
@coordinator = mock('coordinator')
|
||||||
@coordinator.expects(:each).returns(nil)
|
@coordinator.expects(:each).returns(nil)
|
||||||
ENV.delete 'ROLES'
|
ENV.delete 'ROLES'
|
||||||
|
@ -489,14 +489,14 @@ describe Capistrano::DSL do
|
||||||
hosts = dsl.roles(:web)
|
hosts = dsl.roles(:web)
|
||||||
all = dsl.roles(:all)
|
all = dsl.roles(:all)
|
||||||
SSHKit::Coordinator.expects(:new).with(hosts).returns(@coordinator)
|
SSHKit::Coordinator.expects(:new).with(hosts).returns(@coordinator)
|
||||||
dsl.set :filter, { role: 'web' }
|
dsl.set :filter, { :role => 'web' }
|
||||||
dsl.on(all)
|
dsl.on(all)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'filters by host and role from the :filter variable' do
|
it 'filters by host and role from the :filter variable' do
|
||||||
all = dsl.roles(:all)
|
all = dsl.roles(:all)
|
||||||
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
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)
|
dsl.on(all)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -504,14 +504,14 @@ describe Capistrano::DSL do
|
||||||
hosts = dsl.roles(:web)
|
hosts = dsl.roles(:web)
|
||||||
all = dsl.roles(:all)
|
all = dsl.roles(:all)
|
||||||
SSHKit::Coordinator.expects(:new).with(hosts).returns(@coordinator)
|
SSHKit::Coordinator.expects(:new).with(hosts).returns(@coordinator)
|
||||||
dsl.set :filter, { roles: 'web' }
|
dsl.set :filter, { :roles => 'web' }
|
||||||
dsl.on(all)
|
dsl.on(all)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'filters by hosts and roles from the :filter variable' do
|
it 'filters by hosts and roles from the :filter variable' do
|
||||||
all = dsl.roles(:all)
|
all = dsl.roles(:all)
|
||||||
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
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)
|
dsl.on(all)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -551,37 +551,37 @@ describe Capistrano::DSL do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "selects nothing when a role filter is present" do
|
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)
|
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
||||||
dsl.on('my.server')
|
dsl.on('my.server')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "selects using the string when a host filter is present" do
|
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)
|
SSHKit::Coordinator.expects(:new).with(['server.local']).returns(@coordinator)
|
||||||
dsl.on('server.local')
|
dsl.on('server.local')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't select when a host filter is present that doesn't match" do
|
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)
|
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
||||||
dsl.on('server.local')
|
dsl.on('server.local')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "selects nothing when a roles filter is present" do
|
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)
|
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
||||||
dsl.on('my.server')
|
dsl.on('my.server')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "selects using the string when a hosts filter is present" do
|
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)
|
SSHKit::Coordinator.expects(:new).with(['server.local']).returns(@coordinator)
|
||||||
dsl.on('server.local')
|
dsl.on('server.local')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't select when a hosts filter is present that doesn't match" do
|
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)
|
SSHKit::Coordinator.expects(:new).with([]).returns(@coordinator)
|
||||||
dsl.on('server.local')
|
dsl.on('server.local')
|
||||||
end
|
end
|
||||||
|
@ -593,26 +593,26 @@ describe Capistrano::DSL do
|
||||||
describe 'role_properties()' do
|
describe 'role_properties()' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
dsl.role :redis, %w[example1.com example2.com], redis: { port: 6379, type: :slave }
|
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 '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 'example2.com', :roles => %w{web redis}, :web => { :port => 81 }, :redis => { :type => :master }
|
||||||
dsl.server 'example3.com', roles: %w{app}, primary: true
|
dsl.server 'example3.com', :roles => %w{app}, :primary => true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'retrieves properties for a single role as a set' do
|
it 'retrieves properties for a single role as a set' do
|
||||||
rps = dsl.role_properties(:app)
|
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
|
end
|
||||||
|
|
||||||
it 'retrieves properties for multiple roles as a set' do
|
it 'retrieves properties for multiple roles as a set' do
|
||||||
rps = dsl.role_properties(:app, :web)
|
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
|
end
|
||||||
|
|
||||||
it 'yields the properties for a single role' do
|
it 'yields the properties for a single role' do
|
||||||
recipient = mock('recipient')
|
recipient = mock('recipient')
|
||||||
recipient.expects(:doit).with('example1.com', :redis, { port: 6379, type: :slave})
|
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('example2.com', :redis, { :port => 6379, :type => :master})
|
||||||
dsl.role_properties(:redis) do |host, role, props|
|
dsl.role_properties(:redis) do |host, role, props|
|
||||||
recipient.doit(host, role, props)
|
recipient.doit(host, role, props)
|
||||||
end
|
end
|
||||||
|
@ -620,8 +620,8 @@ describe Capistrano::DSL do
|
||||||
|
|
||||||
it 'yields the properties for multiple roles' do
|
it 'yields the properties for multiple roles' do
|
||||||
recipient = mock('recipient')
|
recipient = mock('recipient')
|
||||||
recipient.expects(:doit).with('example1.com', :redis, { port: 6379, type: :slave})
|
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('example2.com', :redis, { :port => 6379, :type => :master})
|
||||||
recipient.expects(:doit).with('example3.com', :app, nil)
|
recipient.expects(:doit).with('example3.com', :app, nil)
|
||||||
dsl.role_properties(:redis, :app) do |host, role, props|
|
dsl.role_properties(:redis, :app) do |host, role, props|
|
||||||
recipient.doit(host, role, props)
|
recipient.doit(host, role, props)
|
||||||
|
@ -630,10 +630,10 @@ describe Capistrano::DSL do
|
||||||
|
|
||||||
it 'yields the merged properties for multiple roles' do
|
it 'yields the merged properties for multiple roles' do
|
||||||
recipient = mock('recipient')
|
recipient = mock('recipient')
|
||||||
recipient.expects(:doit).with('example1.com', :redis, { port: 6379, type: :slave})
|
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('example2.com', :redis, { :port => 6379, :type => :master})
|
||||||
recipient.expects(:doit).with('example1.com', :web, { port: 80 })
|
recipient.expects(:doit).with('example1.com', :web, { :port => 80 })
|
||||||
recipient.expects(:doit).with('example2.com', :web, { port: 81 })
|
recipient.expects(:doit).with('example2.com', :web, { :port => 81 })
|
||||||
dsl.role_properties(:redis, :web) do |host, role, props|
|
dsl.role_properties(:redis, :web) do |host, role, props|
|
||||||
recipient.doit(host, role, props)
|
recipient.doit(host, role, props)
|
||||||
end
|
end
|
||||||
|
@ -641,9 +641,9 @@ describe Capistrano::DSL do
|
||||||
|
|
||||||
it 'honours a property filter before yielding' do
|
it 'honours a property filter before yielding' do
|
||||||
recipient = mock('recipient')
|
recipient = mock('recipient')
|
||||||
recipient.expects(:doit).with('example1.com', :redis, { port: 6379, type: :slave})
|
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', :web, { :port => 80 })
|
||||||
dsl.role_properties(:redis, :web, select: :active) do |host, role, props|
|
dsl.role_properties(:redis, :web, :select => :active) do |host, role, props|
|
||||||
recipient.doit(host, role, props)
|
recipient.doit(host, role, props)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Capistrano
|
||||||
describe Question do
|
describe Question do
|
||||||
|
|
||||||
let(:question) { Question.new(key, default, options) }
|
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(:default) { :default }
|
||||||
let(:key) { :branch }
|
let(:key) { :branch }
|
||||||
let(:options) { nil }
|
let(:options) { nil }
|
||||||
|
|
|
@ -81,7 +81,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'properties contains roles' do
|
context 'properties contains roles' do
|
||||||
let(:properties) { {roles: [:clouds]} }
|
let(:properties) { {:roles => [:clouds]} }
|
||||||
|
|
||||||
it 'adds the roles' do
|
it 'adds the roles' do
|
||||||
expect(server.roles.first).to eq :clouds
|
expect(server.roles.first).to eq :clouds
|
||||||
|
@ -89,7 +89,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'properties contains user' do
|
context 'properties contains user' do
|
||||||
let(:properties) { {user: 'tomc'} }
|
let(:properties) { {:user => 'tomc'} }
|
||||||
|
|
||||||
it 'sets the user' do
|
it 'sets the user' do
|
||||||
expect(server.user).to eq 'tomc'
|
expect(server.user).to eq 'tomc'
|
||||||
|
@ -101,7 +101,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'properties contains port' do
|
context 'properties contains port' do
|
||||||
let(:properties) { {port: 2222} }
|
let(:properties) { {:port => 2222} }
|
||||||
|
|
||||||
it 'sets the port' do
|
it 'sets the port' do
|
||||||
expect(server.port).to eq 2222
|
expect(server.port).to eq 2222
|
||||||
|
@ -109,7 +109,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'properties contains key' do
|
context 'properties contains key' do
|
||||||
let(:properties) { {key: '/key'} }
|
let(:properties) { {:key => '/key'} }
|
||||||
|
|
||||||
it 'adds the key' do
|
it 'adds the key' do
|
||||||
expect(server.keys).to include '/key'
|
expect(server.keys).to include '/key'
|
||||||
|
@ -117,7 +117,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'properties contains password' do
|
context 'properties contains password' do
|
||||||
let(:properties) { {password: 'supersecret'} }
|
let(:properties) { {:password => 'supersecret'} }
|
||||||
|
|
||||||
it 'adds the key' do
|
it 'adds the key' do
|
||||||
expect(server.password).to eq 'supersecret'
|
expect(server.password).to eq 'supersecret'
|
||||||
|
@ -125,7 +125,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'new properties' do
|
context 'new properties' do
|
||||||
let(:properties) { { webscales: 5 } }
|
let(:properties) { { :webscales => 5 } }
|
||||||
|
|
||||||
it 'adds the properties' do
|
it 'adds the properties' do
|
||||||
expect(server.properties.webscales).to eq 5
|
expect(server.properties.webscales).to eq 5
|
||||||
|
@ -133,7 +133,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'existing properties' do
|
context 'existing properties' do
|
||||||
let(:properties) { { webscales: 6 } }
|
let(:properties) { { :webscales => 6 } }
|
||||||
|
|
||||||
it 'keeps the existing properties' do
|
it 'keeps the existing properties' do
|
||||||
expect(server.properties.webscales).to eq 6
|
expect(server.properties.webscales).to eq 6
|
||||||
|
@ -160,46 +160,46 @@ module Capistrano
|
||||||
context 'value matches server property' do
|
context 'value matches server property' do
|
||||||
|
|
||||||
context 'with :filter' do
|
context 'with :filter' do
|
||||||
let(:options) { { filter: :active }}
|
let(:options) { { :filter => :active }}
|
||||||
it { expect(subject).to be_truthy }
|
it { expect(subject).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with :select' do
|
context 'with :select' do
|
||||||
let(:options) { { select: :active }}
|
let(:options) { { :select => :active }}
|
||||||
it { expect(subject).to be_truthy }
|
it { expect(subject).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with :exclude' do
|
context 'with :exclude' do
|
||||||
let(:options) { { exclude: :active }}
|
let(:options) { { :exclude => :active }}
|
||||||
it { expect(subject).to be_falsey }
|
it { expect(subject).to be_falsey }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'value does not match server properly' do
|
context 'value does not match server properly' do
|
||||||
context 'with :active true' do
|
context 'with :active true' do
|
||||||
let(:options) { { active: true }}
|
let(:options) { { :active => true }}
|
||||||
it { expect(subject).to be_truthy }
|
it { expect(subject).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with :active false' do
|
context 'with :active false' do
|
||||||
let(:options) { { active: false }}
|
let(:options) { { :active => false }}
|
||||||
it { expect(subject).to be_falsey }
|
it { expect(subject).to be_falsey }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'value does not match server properly' do
|
context 'value does not match server properly' do
|
||||||
context 'with :filter' do
|
context 'with :filter' do
|
||||||
let(:options) { { filter: :inactive }}
|
let(:options) { { :filter => :inactive }}
|
||||||
it { expect(subject).to be_falsey }
|
it { expect(subject).to be_falsey }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with :select' do
|
context 'with :select' do
|
||||||
let(:options) { { select: :inactive }}
|
let(:options) { { :select => :inactive }}
|
||||||
it { expect(subject).to be_falsey }
|
it { expect(subject).to be_falsey }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with :exclude' do
|
context 'with :exclude' do
|
||||||
let(:options) { { exclude: :inactive }}
|
let(:options) { { :exclude => :inactive }}
|
||||||
it { expect(subject).to be_truthy }
|
it { expect(subject).to be_truthy }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -207,12 +207,12 @@ module Capistrano
|
||||||
|
|
||||||
context 'key is a property' do
|
context 'key is a property' do
|
||||||
context 'with :active true' do
|
context 'with :active true' do
|
||||||
let(:options) { { active: true }}
|
let(:options) { { :active => true }}
|
||||||
it { expect(subject).to be_truthy }
|
it { expect(subject).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with :active false' do
|
context 'with :active false' do
|
||||||
let(:options) { { active: false }}
|
let(:options) { { :active => false }}
|
||||||
it { expect(subject).to be_falsey }
|
it { expect(subject).to be_falsey }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -221,17 +221,17 @@ module Capistrano
|
||||||
context 'value matches server property' do
|
context 'value matches server property' do
|
||||||
|
|
||||||
context 'with :filter' 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 }
|
it { expect(subject).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with :select' do
|
context 'with :select' do
|
||||||
let(:options) { { select: ->(s) { s.properties.active } } }
|
let(:options) { { :select => ->(s) { s.properties.active } } }
|
||||||
it { expect(subject).to be_truthy }
|
it { expect(subject).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with :exclude' do
|
context 'with :exclude' do
|
||||||
let(:options) { { exclude: ->(s) { s.properties.active } } }
|
let(:options) { { :exclude => ->(s) { s.properties.active } } }
|
||||||
it { expect(subject).to be_falsey }
|
it { expect(subject).to be_falsey }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -239,17 +239,17 @@ module Capistrano
|
||||||
|
|
||||||
context 'value does not match server properly' do
|
context 'value does not match server properly' do
|
||||||
context 'with :filter' 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 }
|
it { expect(subject).to be_falsey }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with :select' do
|
context 'with :select' do
|
||||||
let(:options) { { select: ->(s) { s.properties.inactive } } }
|
let(:options) { { :select => ->(s) { s.properties.inactive } } }
|
||||||
it { expect(subject).to be_falsey }
|
it { expect(subject).to be_falsey }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with :exclude' do
|
context 'with :exclude' do
|
||||||
let(:options) { { exclude: ->(s) { s.properties.inactive } } }
|
let(:options) { { :exclude => ->(s) { s.properties.inactive } } }
|
||||||
it { expect(subject).to be_truthy }
|
it { expect(subject).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -272,11 +272,11 @@ module Capistrano
|
||||||
|
|
||||||
context 'custom' do
|
context 'custom' do
|
||||||
let(:properties) do
|
let(:properties) do
|
||||||
{ ssh_options: {
|
{ :ssh_options => {
|
||||||
user: 'another_user',
|
:user => 'another_user',
|
||||||
keys: %w(/home/another_user/.ssh/id_rsa),
|
:keys => %w(/home/another_user/.ssh/id_rsa),
|
||||||
forward_agent: false,
|
:forward_agent => false,
|
||||||
auth_methods: %w(publickey password) } }
|
:auth_methods => %w(publickey password) } }
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -19,8 +19,8 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'handles de-duplification within roles with users' do
|
it 'handles de-duplification within roles with users' do
|
||||||
servers.add_role(:app, %w{1}, user: 'nick')
|
servers.add_role(:app, %w{1}, :user => 'nick')
|
||||||
servers.add_role(:app, %w{1}, user: 'fred')
|
servers.add_role(:app, %w{1}, :user => 'fred')
|
||||||
expect(servers.count).to eq 1
|
expect(servers.count).to eq 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,12 +35,12 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates distinct server properties' do
|
it 'creates distinct server properties' do
|
||||||
servers.add_role(:db, %w{1 2}, db: { port: 1234 } )
|
servers.add_role(:db, %w{1 2}, :db => { :port => 1234 } )
|
||||||
servers.add_host('1', db: { master: true })
|
servers.add_host('1', :db => { :master => true })
|
||||||
expect(servers.count).to eq(2)
|
expect(servers.count).to eq(2)
|
||||||
expect(servers.roles_for([:db]).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 == '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 == '2'}.properties.db).to eq({ :port => 1234 })
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -84,14 +84,14 @@ module Capistrano
|
||||||
|
|
||||||
it 'takes the first server with the primary have the primary flag' do
|
it 'takes the first server with the primary have the primary flag' do
|
||||||
servers.add_role(:app, %w{1 2})
|
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')
|
expect(servers.fetch_primary(:app).hostname).to eq('2')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'ignores any on_filters' do
|
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_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')
|
expect(servers.fetch_primary(:app).hostname).to eq('2')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -122,7 +122,7 @@ module Capistrano
|
||||||
describe 'adding a server' do
|
describe 'adding a server' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
servers.add_host('1', roles: [:app, 'web'], test: :value)
|
servers.add_host('1', :roles => [:app, 'web'], :test => :value)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can create a server with properties' do
|
it 'can create a server with properties' do
|
||||||
|
@ -133,26 +133,26 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can accept multiple servers with the same hostname but different ports or users' do
|
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 => 12)
|
||||||
servers.add_host('1', roles: [:app, 'web'], test: :value, port: 34)
|
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 => 'root')
|
||||||
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer')
|
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 => '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 => 34)
|
||||||
servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 56)
|
servers.add_host('1', :roles => [:app, 'web'], :test => :value, :user => 'deployer', :port => 56)
|
||||||
expect(servers.count).to eq(5)
|
expect(servers.count).to eq(5)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with a :user property" do
|
describe "with a :user property" do
|
||||||
|
|
||||||
it 'sets the server ssh username' 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.count).to eq(1)
|
||||||
expect(servers.roles_for([:all]).first.user).to eq 'nick'
|
expect(servers.roles_for([:all]).first.user).to eq 'nick'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'overwrites the value of a user specified in the hostname' do
|
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.count).to eq(1)
|
||||||
expect(servers.roles_for([:all]).first.user).to eq 'nick'
|
expect(servers.roles_for([:all]).first.user).to eq 'nick'
|
||||||
end
|
end
|
||||||
|
@ -160,47 +160,47 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'overwrites the value of a previously defined scalar property' do
|
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.count).to eq(1)
|
||||||
expect(servers.roles_for([:all]).first.properties.test).to eq :volatile
|
expect(servers.roles_for([:all]).first.properties.test).to eq :volatile
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'merges previously defined hash properties' do
|
it 'merges previously defined hash properties' do
|
||||||
servers.add_host('1', roles: [:b], db: { port: 1234 })
|
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 => { :master => true })
|
||||||
expect(servers.count).to eq(1)
|
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
|
end
|
||||||
|
|
||||||
it 'concatenates previously defined array properties' do
|
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,3,5])
|
||||||
servers.add_host('1', roles: [:b], steps: [1,9])
|
servers.add_host('1', :roles => [:b], :steps => [1,9])
|
||||||
expect(servers.count).to eq(1)
|
expect(servers.count).to eq(1)
|
||||||
expect(servers.roles_for([:b]).first.properties.steps).to eq([1,3,5,1,9])
|
expect(servers.roles_for([:b]).first.properties.steps).to eq([1,3,5,1,9])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'merges previously defined set properties' do
|
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[123,333])
|
||||||
servers.add_host('1', roles: [:b], endpoints: Set[222,333])
|
servers.add_host('1', :roles => [:b], :endpoints => Set[222,333])
|
||||||
expect(servers.count).to eq(1)
|
expect(servers.count).to eq(1)
|
||||||
expect(servers.roles_for([:b]).first.properties.endpoints).to eq(Set[123,222,333])
|
expect(servers.roles_for([:b]).first.properties.endpoints).to eq(Set[123,222,333])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'adds array property value only ones for a new host' do
|
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]
|
expect(servers.roles_for([:array_test]).first.properties.array_property).to eq [1,2]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates roles when custom user defined' do
|
it 'updates roles when custom user defined' do
|
||||||
servers.add_host('1', roles: ['foo'], user: 'custom')
|
servers.add_host('1', :roles => ['foo'], :user => 'custom')
|
||||||
servers.add_host('1', roles: ['bar'], user: 'custom')
|
servers.add_host('1', :roles => ['bar'], :user => 'custom')
|
||||||
expect(servers.roles_for([:foo]).first.hostname).to eq '1'
|
expect(servers.roles_for([:foo]).first.hostname).to eq '1'
|
||||||
expect(servers.roles_for([:bar]).first.hostname).to eq '1'
|
expect(servers.roles_for([:bar]).first.hostname).to eq '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates roles when custom port defined' do
|
it 'updates roles when custom port defined' do
|
||||||
servers.add_host('1', roles: ['foo'], port: 1234)
|
servers.add_host('1', :roles => ['foo'], :port => 1234)
|
||||||
servers.add_host('1', roles: ['bar'], port: 1234)
|
servers.add_host('1', :roles => ['bar'], :port => 1234)
|
||||||
expect(servers.roles_for([:foo]).first.hostname).to eq '1'
|
expect(servers.roles_for([:foo]).first.hostname).to eq '1'
|
||||||
expect(servers.roles_for([:bar]).first.hostname).to eq '1'
|
expect(servers.roles_for([:bar]).first.hostname).to eq '1'
|
||||||
end
|
end
|
||||||
|
@ -210,32 +210,32 @@ module Capistrano
|
||||||
describe 'selecting roles' do
|
describe 'selecting roles' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
servers.add_host('1', roles: :app, active: true)
|
servers.add_host('1', :roles => :app, :active => true)
|
||||||
servers.add_host('2', roles: :app)
|
servers.add_host('2', :roles => :app)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is empty if the filter would remove all matching hosts' do
|
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
|
end
|
||||||
|
|
||||||
it 'can filter hosts by properties on the host object using symbol as shorthand' do
|
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
|
end
|
||||||
|
|
||||||
it 'can select hosts by properties on the host object using symbol as shorthand' do
|
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
|
end
|
||||||
|
|
||||||
it 'can filter hosts by properties on the host using a regular proc' do
|
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
|
end
|
||||||
|
|
||||||
it 'can select hosts by properties on the host using a regular proc' do
|
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
|
end
|
||||||
|
|
||||||
it 'is empty if the regular proc filter would remove all matching hosts' do
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -243,27 +243,27 @@ module Capistrano
|
||||||
describe 'excluding by property' do
|
describe 'excluding by property' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
servers.add_host('1', roles: :app, active: true)
|
servers.add_host('1', :roles => :app, :active => true)
|
||||||
servers.add_host('2', roles: :app, active: true, no_release: true)
|
servers.add_host('2', :roles => :app, :active => true, :no_release => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is empty if the filter would remove all matching hosts' do
|
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
|
expect(hosts.map(&:hostname)).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the servers without the attributes specified' do
|
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}
|
expect(hosts.map(&:hostname)).to eq %w{1}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can exclude hosts by properties on the host using a regular proc' do
|
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}
|
expect(hosts.map(&:hostname)).to eq %w{1}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is empty if the regular proc filter would remove all matching hosts' do
|
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
|
expect(hosts.map(&:hostname)).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -272,11 +272,11 @@ module Capistrano
|
||||||
describe 'filtering roles internally' do
|
describe 'filtering roles internally' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
servers.add_host('1', roles: :app, active: true)
|
servers.add_host('1', :roles => :app, :active => true)
|
||||||
servers.add_host('2', roles: :app)
|
servers.add_host('2', :roles => :app)
|
||||||
servers.add_host('3', roles: :web)
|
servers.add_host('3', :roles => :web)
|
||||||
servers.add_host('4', roles: :web)
|
servers.add_host('4', :roles => :web)
|
||||||
servers.add_host('5', roles: :db)
|
servers.add_host('5', :roles => :db)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { servers.roles_for(roles).map(&:hostname) }
|
subject { servers.roles_for(roles).map(&:hostname) }
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Capistrano
|
||||||
|
|
||||||
describe '.new' do
|
describe '.new' do
|
||||||
it 'accepts initial hash' 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')
|
expect(configuration.fetch(:custom)).to eq('value')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -262,10 +262,10 @@ module Capistrano
|
||||||
it 'merges them with the :ssh_options variable' do
|
it 'merges them with the :ssh_options variable' do
|
||||||
config.set :format, :pretty
|
config.set :format, :pretty
|
||||||
config.set :log_level, :debug
|
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
|
SSHKit::Backend::Netssh.configure do |ssh| ssh.ssh_options = { :password => 'einstein' } end
|
||||||
config.configure_backend
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,11 +12,11 @@ module Capistrano
|
||||||
|
|
||||||
describe '#t' do
|
describe '#t' do
|
||||||
before do
|
before do
|
||||||
I18n.expects(:t).with(:phrase, {count: 2, scope: :capistrano})
|
I18n.expects(:t).with(:phrase, {:count => 2, :scope => :capistrano})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'delegates to I18n' do
|
it 'delegates to I18n' do
|
||||||
dsl.t(:phrase, count: 2)
|
dsl.t(:phrase, :count => 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
8
spec/support/Vagrantfile
vendored
8
spec/support/Vagrantfile
vendored
|
@ -5,16 +5,16 @@ Vagrant.configure("2") do |config|
|
||||||
config.ssh.insert_key = false
|
config.ssh.insert_key = false
|
||||||
|
|
||||||
[:app].each_with_index do |role, i|
|
[: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.define role
|
||||||
primary.vm.box = 'hashicorp/precise64'
|
primary.vm.box = 'hashicorp/precise64'
|
||||||
primary.vm.network "forwarded_port", guest: 22, host: "222#{i}".to_i
|
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.provision :shell, :inline => 'sudo apt-get -y install git-core'
|
||||||
|
|
||||||
vagrantkey = open("https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub", "r",&:read)
|
vagrantkey = open("https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub", "r",&:read)
|
||||||
|
|
||||||
primary.vm.provision :shell,
|
primary.vm.provision :shell,
|
||||||
inline: <<-INLINE
|
:inline => <<-INLINE
|
||||||
install -d -m 700 /root/.ssh
|
install -d -m 700 /root/.ssh
|
||||||
echo -e "#{vagrantkey}" > /root/.ssh/authorized_keys
|
echo -e "#{vagrantkey}" > /root/.ssh/authorized_keys
|
||||||
chmod 0600 /root/.ssh/authorized_keys
|
chmod 0600 /root/.ssh/authorized_keys
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace :deploy do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
remote_file 'config/database.yml' => '/tmp/database.yml', roles: :all
|
remote_file 'config/database.yml' => '/tmp/database.yml', :roles => :all
|
||||||
|
|
||||||
file '/tmp/database.yml' do |t|
|
file '/tmp/database.yml' do |t|
|
||||||
sh "touch #{t.name}"
|
sh "touch #{t.name}"
|
||||||
|
|
Loading…
Reference in a new issue