capistrano 3.4.1 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -5
  3. data/.rubocop.yml +49 -0
  4. data/.travis.yml +5 -4
  5. data/CHANGELOG.md +72 -9
  6. data/CONTRIBUTING.md +61 -93
  7. data/DEVELOPMENT.md +122 -0
  8. data/Gemfile +2 -2
  9. data/LICENSE.txt +1 -1
  10. data/README.md +121 -43
  11. data/RELEASING.md +16 -0
  12. data/Rakefile +4 -1
  13. data/bin/cap +1 -1
  14. data/capistrano.gemspec +16 -21
  15. data/features/doctor.feature +11 -0
  16. data/features/step_definitions/assertions.rb +17 -17
  17. data/features/step_definitions/cap_commands.rb +0 -1
  18. data/features/step_definitions/setup.rb +12 -8
  19. data/features/support/env.rb +5 -5
  20. data/features/support/remote_command_helpers.rb +8 -6
  21. data/features/support/vagrant_helpers.rb +5 -4
  22. data/issue_template.md +21 -0
  23. data/lib/Capfile +5 -1
  24. data/lib/capistrano/all.rb +9 -10
  25. data/lib/capistrano/application.rb +36 -26
  26. data/lib/capistrano/configuration.rb +56 -41
  27. data/lib/capistrano/configuration/empty_filter.rb +9 -0
  28. data/lib/capistrano/configuration/filter.rb +18 -47
  29. data/lib/capistrano/configuration/host_filter.rb +30 -0
  30. data/lib/capistrano/configuration/null_filter.rb +9 -0
  31. data/lib/capistrano/configuration/plugin_installer.rb +33 -0
  32. data/lib/capistrano/configuration/question.rb +10 -7
  33. data/lib/capistrano/configuration/role_filter.rb +30 -0
  34. data/lib/capistrano/configuration/server.rb +22 -23
  35. data/lib/capistrano/configuration/servers.rb +6 -7
  36. data/lib/capistrano/configuration/variables.rb +136 -0
  37. data/lib/capistrano/defaults.rb +13 -3
  38. data/lib/capistrano/deploy.rb +1 -1
  39. data/lib/capistrano/doctor.rb +5 -0
  40. data/lib/capistrano/doctor/environment_doctor.rb +19 -0
  41. data/lib/capistrano/doctor/gems_doctor.rb +45 -0
  42. data/lib/capistrano/doctor/output_helpers.rb +79 -0
  43. data/lib/capistrano/doctor/variables_doctor.rb +66 -0
  44. data/lib/capistrano/dotfile.rb +1 -2
  45. data/lib/capistrano/dsl.rb +12 -14
  46. data/lib/capistrano/dsl/env.rb +11 -42
  47. data/lib/capistrano/dsl/paths.rb +12 -13
  48. data/lib/capistrano/dsl/stages.rb +2 -4
  49. data/lib/capistrano/dsl/task_enhancements.rb +5 -7
  50. data/lib/capistrano/framework.rb +1 -1
  51. data/lib/capistrano/git.rb +17 -9
  52. data/lib/capistrano/hg.rb +4 -4
  53. data/lib/capistrano/i18n.rb +24 -24
  54. data/lib/capistrano/immutable_task.rb +29 -0
  55. data/lib/capistrano/install.rb +1 -1
  56. data/lib/capistrano/plugin.rb +95 -0
  57. data/lib/capistrano/scm.rb +7 -20
  58. data/lib/capistrano/setup.rb +19 -5
  59. data/lib/capistrano/svn.rb +9 -5
  60. data/lib/capistrano/tasks/console.rake +4 -8
  61. data/lib/capistrano/tasks/deploy.rake +75 -62
  62. data/lib/capistrano/tasks/doctor.rake +19 -0
  63. data/lib/capistrano/tasks/framework.rake +13 -14
  64. data/lib/capistrano/tasks/git.rake +10 -11
  65. data/lib/capistrano/tasks/hg.rake +7 -7
  66. data/lib/capistrano/tasks/install.rake +14 -15
  67. data/lib/capistrano/tasks/svn.rake +7 -7
  68. data/lib/capistrano/templates/Capfile +3 -3
  69. data/lib/capistrano/templates/deploy.rb.erb +6 -5
  70. data/lib/capistrano/upload_task.rb +1 -1
  71. data/lib/capistrano/version.rb +1 -1
  72. data/lib/capistrano/version_validator.rb +4 -6
  73. data/spec/integration/dsl_spec.rb +286 -239
  74. data/spec/integration_spec_helper.rb +3 -5
  75. data/spec/lib/capistrano/application_spec.rb +22 -14
  76. data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
  77. data/spec/lib/capistrano/configuration/filter_spec.rb +82 -84
  78. data/spec/lib/capistrano/configuration/host_filter_spec.rb +61 -0
  79. data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
  80. data/spec/lib/capistrano/configuration/question_spec.rb +12 -16
  81. data/spec/lib/capistrano/configuration/role_filter_spec.rb +64 -0
  82. data/spec/lib/capistrano/configuration/server_spec.rb +102 -110
  83. data/spec/lib/capistrano/configuration/servers_spec.rb +124 -141
  84. data/spec/lib/capistrano/configuration_spec.rb +150 -61
  85. data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
  86. data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +61 -0
  87. data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
  88. data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +79 -0
  89. data/spec/lib/capistrano/dsl/paths_spec.rb +58 -50
  90. data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +62 -32
  91. data/spec/lib/capistrano/dsl_spec.rb +6 -8
  92. data/spec/lib/capistrano/git_spec.rb +35 -7
  93. data/spec/lib/capistrano/hg_spec.rb +14 -5
  94. data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
  95. data/spec/lib/capistrano/plugin_spec.rb +84 -0
  96. data/spec/lib/capistrano/scm_spec.rb +6 -7
  97. data/spec/lib/capistrano/svn_spec.rb +40 -14
  98. data/spec/lib/capistrano/upload_task_spec.rb +7 -7
  99. data/spec/lib/capistrano/version_validator_spec.rb +37 -45
  100. data/spec/lib/capistrano_spec.rb +2 -3
  101. data/spec/spec_helper.rb +8 -8
  102. data/spec/support/Vagrantfile +9 -10
  103. data/spec/support/tasks/database.rake +3 -3
  104. data/spec/support/tasks/fail.rake +4 -3
  105. data/spec/support/tasks/failed.rake +2 -2
  106. data/spec/support/tasks/plugin.rake +6 -0
  107. data/spec/support/tasks/root.rake +4 -4
  108. data/spec/support/test_app.rb +31 -30
  109. metadata +93 -14
@@ -1,63 +1,60 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Capistrano
4
4
  class Configuration
5
5
  describe Servers do
6
6
  let(:servers) { Servers.new }
7
7
 
8
- describe 'adding a role' do
9
-
10
- it 'adds two new server instances' do
11
- expect{servers.add_role(:app, %w{1 2})}.
12
- to change{servers.count}.from(0).to(2)
8
+ describe "adding a role" do
9
+ it "adds two new server instances" do
10
+ expect { servers.add_role(:app, %w{1 2}) }
11
+ .to change { servers.count }.from(0).to(2)
13
12
  end
14
13
 
15
- it 'handles de-duplification within roles' do
14
+ it "handles de-duplification within roles" do
16
15
  servers.add_role(:app, %w{1})
17
16
  servers.add_role(:app, %w{1})
18
17
  expect(servers.count).to eq 1
19
18
  end
20
19
 
21
- it 'handles de-duplification within roles with users' do
22
- servers.add_role(:app, %w{1}, user: 'nick')
23
- servers.add_role(:app, %w{1}, user: 'fred')
20
+ it "handles de-duplification within roles with users" do
21
+ servers.add_role(:app, %w{1}, user: "nick")
22
+ servers.add_role(:app, %w{1}, user: "fred")
24
23
  expect(servers.count).to eq 1
25
24
  end
26
25
 
27
- it 'accepts instances of server objects' do
28
- servers.add_role(:app, [Capistrano::Configuration::Server.new('example.net'), 'example.com'])
26
+ it "accepts instances of server objects" do
27
+ servers.add_role(:app, [Capistrano::Configuration::Server.new("example.net"), "example.com"])
29
28
  expect(servers.roles_for([:app]).length).to eq 2
30
29
  end
31
30
 
32
- it 'accepts non-enumerable types' do
33
- servers.add_role(:app, '1')
31
+ it "accepts non-enumerable types" do
32
+ servers.add_role(:app, "1")
34
33
  expect(servers.roles_for([:app]).count).to eq 1
35
34
  end
36
35
 
37
- it 'creates distinct server properties' do
38
- servers.add_role(:db, %w{1 2}, db: { port: 1234 } )
39
- servers.add_host('1', db: { master: true })
36
+ it "creates distinct server properties" do
37
+ servers.add_role(:db, %w{1 2}, db: { port: 1234 })
38
+ servers.add_host("1", db: { master: true })
40
39
  expect(servers.count).to eq(2)
41
40
  expect(servers.roles_for([:db]).count).to eq 2
42
- expect(servers.find(){|s| s.hostname == '1'}.properties.db).to eq({ port: 1234, master: true })
43
- expect(servers.find(){|s| s.hostname == '2'}.properties.db).to eq({ port: 1234 })
41
+ expect(servers.find { |s| s.hostname == "1" }.properties.db).to eq(port: 1234, master: true)
42
+ expect(servers.find { |s| s.hostname == "2" }.properties.db).to eq(port: 1234)
44
43
  end
45
-
46
44
  end
47
45
 
48
- describe 'adding a role to an existing server' do
46
+ describe "adding a role to an existing server" do
49
47
  before do
50
48
  servers.add_role(:web, %w{1 2})
51
49
  servers.add_role(:app, %w{1 2})
52
50
  end
53
51
 
54
- it 'adds new roles to existing servers' do
52
+ it "adds new roles to existing servers" do
55
53
  expect(servers.count).to eq 2
56
54
  end
57
-
58
55
  end
59
56
 
60
- describe 'collecting server roles' do
57
+ describe "collecting server roles" do
61
58
  let(:app) { Set.new([:app]) }
62
59
  let(:web_app) { Set.new([:web, :app]) }
63
60
  let(:web) { Set.new([:web]) }
@@ -67,280 +64,266 @@ module Capistrano
67
64
  servers.add_role(:web, %w{2 3 4})
68
65
  end
69
66
 
70
- it 'returns an array of the roles' do
67
+ it "returns an array of the roles" do
71
68
  expect(servers.roles_for([:app]).collect(&:roles)).to eq [app, web_app, web_app]
72
69
  expect(servers.roles_for([:web]).collect(&:roles)).to eq [web_app, web_app, web]
73
70
  end
74
71
  end
75
72
 
76
- describe 'finding the primary server' do
73
+ describe "finding the primary server" do
77
74
  after do
78
75
  Configuration.reset!
79
76
  end
80
- it 'takes the first server if none have the primary property' do
77
+ it "takes the first server if none have the primary property" do
81
78
  servers.add_role(:app, %w{1 2})
82
- expect(servers.fetch_primary(:app).hostname).to eq('1')
79
+ expect(servers.fetch_primary(:app).hostname).to eq("1")
83
80
  end
84
81
 
85
- it 'takes the first server with the primary have the primary flag' do
82
+ it "takes the first server with the primary have the primary flag" do
86
83
  servers.add_role(:app, %w{1 2})
87
- servers.add_host('2', primary: true)
88
- expect(servers.fetch_primary(:app).hostname).to eq('2')
84
+ servers.add_host("2", primary: true)
85
+ expect(servers.fetch_primary(:app).hostname).to eq("2")
89
86
  end
90
87
 
91
- it 'ignores any on_filters' do
92
- Configuration.env.set :filter, { host: '1'}
88
+ it "ignores any on_filters" do
89
+ Configuration.env.set :filter, host: "1"
93
90
  servers.add_role(:app, %w{1 2})
94
- servers.add_host('2', primary: true)
95
- expect(servers.fetch_primary(:app).hostname).to eq('2')
91
+ servers.add_host("2", primary: true)
92
+ expect(servers.fetch_primary(:app).hostname).to eq("2")
96
93
  end
97
94
  end
98
95
 
99
- describe 'fetching servers' do
96
+ describe "fetching servers" do
100
97
  before do
101
98
  servers.add_role(:app, %w{1 2})
102
99
  servers.add_role(:web, %w{2 3})
103
100
  end
104
101
 
105
- it 'returns the correct app servers' do
102
+ it "returns the correct app servers" do
106
103
  expect(servers.roles_for([:app]).map(&:hostname)).to eq %w{1 2}
107
104
  end
108
105
 
109
- it 'returns the correct web servers' do
106
+ it "returns the correct web servers" do
110
107
  expect(servers.roles_for([:web]).map(&:hostname)).to eq %w{2 3}
111
108
  end
112
109
 
113
- it 'returns the correct app and web servers' do
110
+ it "returns the correct app and web servers" do
114
111
  expect(servers.roles_for([:app, :web]).map(&:hostname)).to eq %w{1 2 3}
115
112
  end
116
113
 
117
- it 'returns all servers' do
114
+ it "returns all servers" do
118
115
  expect(servers.roles_for([:all]).map(&:hostname)).to eq %w{1 2 3}
119
116
  end
120
117
  end
121
118
 
122
- describe 'adding a server' do
123
-
119
+ describe "adding a server" do
124
120
  before do
125
- servers.add_host('1', roles: [:app, 'web'], test: :value)
121
+ servers.add_host("1", roles: [:app, "web"], test: :value)
126
122
  end
127
123
 
128
- it 'can create a server with properties' do
129
- expect(servers.roles_for([:app]).first.hostname).to eq '1'
130
- expect(servers.roles_for([:web]).first.hostname).to eq '1'
124
+ it "can create a server with properties" do
125
+ expect(servers.roles_for([:app]).first.hostname).to eq "1"
126
+ expect(servers.roles_for([:web]).first.hostname).to eq "1"
131
127
  expect(servers.roles_for([:all]).first.properties.test).to eq :value
132
128
  expect(servers.roles_for([:all]).first.properties.keys).to eq [:test]
133
129
  end
134
130
 
135
- it 'can accept multiple servers with the same hostname but different ports or users' do
136
- servers.add_host('1', roles: [:app, 'web'], test: :value, port: 12)
137
- servers.add_host('1', roles: [:app, 'web'], test: :value, port: 34)
138
- servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'root')
139
- servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer')
140
- servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'root', port: 34)
141
- servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 34)
142
- servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 56)
143
- expect(servers.count).to eq(1)
131
+ it "can accept multiple servers with the same hostname but different ports or users" do
132
+ servers.add_host("1", roles: [:app, "web"], test: :value, port: 12)
133
+ servers.add_host("1", roles: [:app, "web"], test: :value, port: 34)
134
+ servers.add_host("1", roles: [:app, "web"], test: :value, user: "root")
135
+ servers.add_host("1", roles: [:app, "web"], test: :value, user: "deployer")
136
+ servers.add_host("1", roles: [:app, "web"], test: :value, user: "root", port: 34)
137
+ servers.add_host("1", roles: [:app, "web"], test: :value, user: "deployer", port: 34)
138
+ servers.add_host("1", roles: [:app, "web"], test: :value, user: "deployer", port: 56)
139
+ expect(servers.count).to eq(5)
144
140
  end
145
141
 
146
142
  describe "with a :user property" do
147
-
148
- it 'sets the server ssh username' do
149
- servers.add_host('1', roles: [:app, 'web'], user: 'nick')
143
+ it "sets the server ssh username" do
144
+ servers.add_host("1", roles: [:app, "web"], user: "nick")
150
145
  expect(servers.count).to eq(1)
151
- expect(servers.roles_for([:all]).first.user).to eq 'nick'
146
+ expect(servers.roles_for([:all]).first.user).to eq "nick"
152
147
  end
153
148
 
154
- it 'overwrites the value of a user specified in the hostname' do
155
- servers.add_host('brian@1', roles: [:app, 'web'], user: 'nick')
149
+ it "overwrites the value of a user specified in the hostname" do
150
+ servers.add_host("brian@1", roles: [:app, "web"], user: "nick")
156
151
  expect(servers.count).to eq(1)
157
- expect(servers.roles_for([:all]).first.user).to eq 'nick'
152
+ expect(servers.roles_for([:all]).first.user).to eq "nick"
158
153
  end
159
-
160
154
  end
161
155
 
162
- it 'overwrites the value of a previously defined scalar property' do
163
- servers.add_host('1', roles: [:app, 'web'], test: :volatile)
156
+ it "overwrites the value of a previously defined scalar property" do
157
+ servers.add_host("1", roles: [:app, "web"], test: :volatile)
164
158
  expect(servers.count).to eq(1)
165
159
  expect(servers.roles_for([:all]).first.properties.test).to eq :volatile
166
160
  end
167
161
 
168
- it 'merges previously defined hash properties' do
169
- servers.add_host('1', roles: [:b], db: { port: 1234 })
170
- servers.add_host('1', roles: [:b], db: { master: true })
162
+ it "merges previously defined hash properties" do
163
+ servers.add_host("1", roles: [:b], db: { port: 1234 })
164
+ servers.add_host("1", roles: [:b], db: { master: true })
171
165
  expect(servers.count).to eq(1)
172
- expect(servers.roles_for([:b]).first.properties.db).to eq({ port: 1234, master: true })
166
+ expect(servers.roles_for([:b]).first.properties.db).to eq(port: 1234, master: true)
173
167
  end
174
168
 
175
- it 'concatenates previously defined array properties' do
176
- servers.add_host('1', roles: [:b], steps: [1,3,5])
177
- servers.add_host('1', roles: [:b], steps: [1,9])
169
+ it "concatenates previously defined array properties" do
170
+ servers.add_host("1", roles: [:b], steps: [1, 3, 5])
171
+ servers.add_host("1", roles: [:b], steps: [1, 9])
178
172
  expect(servers.count).to eq(1)
179
- expect(servers.roles_for([:b]).first.properties.steps).to eq([1,3,5,1,9])
173
+ expect(servers.roles_for([:b]).first.properties.steps).to eq([1, 3, 5, 1, 9])
180
174
  end
181
175
 
182
- it 'merges previously defined set properties' do
183
- servers.add_host('1', roles: [:b], endpoints: Set[123,333])
184
- servers.add_host('1', roles: [:b], endpoints: Set[222,333])
176
+ it "merges previously defined set properties" do
177
+ servers.add_host("1", roles: [:b], endpoints: Set[123, 333])
178
+ servers.add_host("1", roles: [:b], endpoints: Set[222, 333])
185
179
  expect(servers.count).to eq(1)
186
- expect(servers.roles_for([:b]).first.properties.endpoints).to eq(Set[123,222,333])
180
+ expect(servers.roles_for([:b]).first.properties.endpoints).to eq(Set[123, 222, 333])
187
181
  end
188
182
 
189
- it 'adds array property value only ones for a new host' do
190
- servers.add_host('2', roles: [:array_test], array_property: [1,2])
191
- expect(servers.roles_for([:array_test]).first.properties.array_property).to eq [1,2]
183
+ it "adds array property value only ones for a new host" do
184
+ servers.add_host("2", roles: [:array_test], array_property: [1, 2])
185
+ expect(servers.roles_for([:array_test]).first.properties.array_property).to eq [1, 2]
192
186
  end
193
187
 
194
- it 'updates roles when custom user defined' do
195
- servers.add_host('1', roles: ['foo'], user: 'custom')
196
- servers.add_host('1', roles: ['bar'], user: 'custom')
197
- expect(servers.roles_for([:foo]).first.hostname).to eq '1'
198
- expect(servers.roles_for([:bar]).first.hostname).to eq '1'
188
+ it "updates roles when custom user defined" do
189
+ servers.add_host("1", roles: ["foo"], user: "custom")
190
+ servers.add_host("1", roles: ["bar"], user: "custom")
191
+ expect(servers.roles_for([:foo]).first.hostname).to eq "1"
192
+ expect(servers.roles_for([:bar]).first.hostname).to eq "1"
199
193
  end
200
194
 
201
- it 'updates roles when custom port defined' do
202
- servers.add_host('1', roles: ['foo'], port: 1234)
203
- servers.add_host('1', roles: ['bar'], port: 1234)
204
- expect(servers.roles_for([:foo]).first.hostname).to eq '1'
205
- expect(servers.roles_for([:bar]).first.hostname).to eq '1'
195
+ it "updates roles when custom port defined" do
196
+ servers.add_host("1", roles: ["foo"], port: 1234)
197
+ servers.add_host("1", roles: ["bar"], port: 1234)
198
+ expect(servers.roles_for([:foo]).first.hostname).to eq "1"
199
+ expect(servers.roles_for([:bar]).first.hostname).to eq "1"
206
200
  end
207
-
208
201
  end
209
202
 
210
- describe 'selecting roles' do
211
-
203
+ describe "selecting roles" do
212
204
  before do
213
- servers.add_host('1', roles: :app, active: true)
214
- servers.add_host('2', roles: :app)
205
+ servers.add_host("1", roles: :app, active: true)
206
+ servers.add_host("2", roles: :app)
215
207
  end
216
208
 
217
- it 'is empty if the filter would remove all matching hosts' do
209
+ it "is empty if the filter would remove all matching hosts" do
218
210
  expect(servers.roles_for([:app, select: :inactive])).to be_empty
219
211
  end
220
212
 
221
- it 'can filter hosts by properties on the host object using symbol as shorthand' do
213
+ it "can filter hosts by properties on the host object using symbol as shorthand" do
222
214
  expect(servers.roles_for([:app, filter: :active]).length).to eq 1
223
215
  end
224
216
 
225
- it 'can select hosts by properties on the host object using symbol as shorthand' do
217
+ it "can select hosts by properties on the host object using symbol as shorthand" do
226
218
  expect(servers.roles_for([:app, select: :active]).length).to eq 1
227
219
  end
228
220
 
229
- it 'can filter hosts by properties on the host using a regular proc' do
221
+ it "can filter hosts by properties on the host using a regular proc" do
230
222
  expect(servers.roles_for([:app, filter: ->(h) { h.properties.active }]).length).to eq 1
231
223
  end
232
224
 
233
- it 'can select hosts by properties on the host using a regular proc' do
225
+ it "can select hosts by properties on the host using a regular proc" do
234
226
  expect(servers.roles_for([:app, select: ->(h) { h.properties.active }]).length).to eq 1
235
227
  end
236
228
 
237
- it 'is empty if the regular proc filter would remove all matching hosts' do
229
+ it "is empty if the regular proc filter would remove all matching hosts" do
238
230
  expect(servers.roles_for([:app, select: ->(h) { h.properties.inactive }])).to be_empty
239
231
  end
240
-
241
232
  end
242
233
 
243
- describe 'excluding by property' do
244
-
234
+ describe "excluding by property" do
245
235
  before do
246
- servers.add_host('1', roles: :app, active: true)
247
- servers.add_host('2', roles: :app, active: true, no_release: true)
236
+ servers.add_host("1", roles: :app, active: true)
237
+ servers.add_host("2", roles: :app, active: true, no_release: true)
248
238
  end
249
239
 
250
- it 'is empty if the filter would remove all matching hosts' do
240
+ it "is empty if the filter would remove all matching hosts" do
251
241
  hosts = servers.roles_for([:app, exclude: :active])
252
242
  expect(hosts.map(&:hostname)).to be_empty
253
243
  end
254
244
 
255
- it 'returns the servers without the attributes specified' do
245
+ it "returns the servers without the attributes specified" do
256
246
  hosts = servers.roles_for([:app, exclude: :no_release])
257
247
  expect(hosts.map(&:hostname)).to eq %w{1}
258
248
  end
259
249
 
260
- it 'can exclude hosts by properties on the host using a regular proc' do
250
+ it "can exclude hosts by properties on the host using a regular proc" do
261
251
  hosts = servers.roles_for([:app, exclude: ->(h) { h.properties.no_release }])
262
252
  expect(hosts.map(&:hostname)).to eq %w{1}
263
253
  end
264
254
 
265
- it 'is empty if the regular proc filter would remove all matching hosts' do
255
+ it "is empty if the regular proc filter would remove all matching hosts" do
266
256
  hosts = servers.roles_for([:app, exclude: ->(h) { h.properties.active }])
267
257
  expect(hosts.map(&:hostname)).to be_empty
268
258
  end
269
-
270
259
  end
271
260
 
272
- describe 'filtering roles internally' do
273
-
261
+ describe "filtering roles internally" do
274
262
  before do
275
- servers.add_host('1', roles: :app, active: true)
276
- servers.add_host('2', roles: :app)
277
- servers.add_host('3', roles: :web)
278
- servers.add_host('4', roles: :web)
279
- servers.add_host('5', roles: :db)
263
+ servers.add_host("1", roles: :app, active: true)
264
+ servers.add_host("2", roles: :app)
265
+ servers.add_host("3", roles: :web)
266
+ servers.add_host("4", roles: :web)
267
+ servers.add_host("5", roles: :db)
280
268
  end
281
269
 
282
270
  subject { servers.roles_for(roles).map(&:hostname) }
283
271
 
284
- context 'with the ROLES environment variable set' do
285
-
272
+ context "with the ROLES environment variable set" do
286
273
  before do
287
- ENV.stubs(:[]).with('ROLES').returns('web,db')
288
- ENV.stubs(:[]).with('HOSTS').returns(nil)
274
+ ENV.stubs(:[]).with("ROLES").returns("web,db")
275
+ ENV.stubs(:[]).with("HOSTS").returns(nil)
289
276
  end
290
277
 
291
- context 'when selecting all roles' do
278
+ context "when selecting all roles" do
292
279
  let(:roles) { [:all] }
293
- it 'ignores it' do
280
+ it "ignores it" do
294
281
  expect(subject).to eq %w{1 2 3 4 5}
295
282
  end
296
283
  end
297
284
 
298
- context 'when selecting specific roles' do
285
+ context "when selecting specific roles" do
299
286
  let(:roles) { [:app, :web] }
300
- it 'ignores it' do
287
+ it "ignores it" do
301
288
  expect(subject).to eq %w{1 2 3 4}
302
289
  end
303
290
  end
304
291
 
305
- context 'when selecting roles not included in ROLE' do
292
+ context "when selecting roles not included in ROLE" do
306
293
  let(:roles) { [:app] }
307
- it 'ignores it' do
294
+ it "ignores it" do
308
295
  expect(subject).to eq %w{1 2}
309
296
  end
310
297
  end
311
-
312
298
  end
313
299
 
314
- context 'with the HOSTS environment variable set' do
315
-
300
+ context "with the HOSTS environment variable set" do
316
301
  before do
317
- ENV.stubs(:[]).with('ROLES').returns(nil)
318
- ENV.stubs(:[]).with('HOSTS').returns('3,5')
302
+ ENV.stubs(:[]).with("ROLES").returns(nil)
303
+ ENV.stubs(:[]).with("HOSTS").returns("3,5")
319
304
  end
320
305
 
321
- context 'when selecting all roles' do
306
+ context "when selecting all roles" do
322
307
  let(:roles) { [:all] }
323
- it 'ignores it' do
308
+ it "ignores it" do
324
309
  expect(subject).to eq %w{1 2 3 4 5}
325
310
  end
326
311
  end
327
312
 
328
- context 'when selecting specific roles' do
313
+ context "when selecting specific roles" do
329
314
  let(:roles) { [:app, :web] }
330
- it 'ignores it' do
315
+ it "ignores it" do
331
316
  expect(subject).to eq %w{1 2 3 4}
332
317
  end
333
318
  end
334
319
 
335
- context 'when selecting no roles' do
320
+ context "when selecting no roles" do
336
321
  let(:roles) { [] }
337
- it 'ignores it' do
322
+ it "ignores it" do
338
323
  expect(subject).to be_empty
339
324
  end
340
325
  end
341
-
342
326
  end
343
-
344
327
  end
345
328
  end
346
329
  end