1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Warn developers that :all is a meta role

Fix for #705
This commit is contained in:
Kir Shatrov 2013-10-17 12:38:48 +02:00
parent a4db00e77e
commit 51d5d1ecd9
3 changed files with 13 additions and 0 deletions

View file

@ -34,6 +34,10 @@ module Capistrano
end
def role(name, hosts, options={})
if name == :all
raise ArgumentError.new("#{name} reserved name for role. Please choose another name")
end
servers.add_role(name, hosts, options)
end

View file

@ -5,6 +5,7 @@ set :stage, :<%= stage %>
# Supports bulk-adding hosts to roles, the primary
# server in each group is considered to be the first
# unless any hosts have the primary property set.
# Don't declare `role :all`, it's a meta role
role :app, %w{deploy@example.com}
role :web, %w{deploy@example.com}
role :db, %w{deploy@example.com}

View file

@ -70,6 +70,14 @@ describe Capistrano::DSL do
end
describe 'when defining role with reserved name' do
it 'fails with ArgumentError' do
expect {
dsl.role :all, %w{example1.com}
}.to raise_error(ArgumentError, "all reserved name for role. Please choose another name")
end
end
describe 'when defining hosts using the `role` syntax' do
before do
dsl.role :web, %w{example1.com example2.com example3.com}