beaker-puppet 1.29.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.github/workflows/release.yml +2 -2
  4. data/.github/workflows/test.yml +28 -7
  5. data/.rubocop.yml +5 -0
  6. data/.rubocop_todo.yml +842 -0
  7. data/CHANGELOG.md +31 -0
  8. data/Gemfile +5 -20
  9. data/Rakefile +64 -169
  10. data/acceptance/config/acceptance-options.rb +3 -3
  11. data/acceptance/config/gem/acceptance-options.rb +8 -8
  12. data/acceptance/config/git/acceptance-options.rb +8 -8
  13. data/acceptance/config/pkg/acceptance-options.rb +7 -7
  14. data/acceptance/pre_suite/gem/install.rb +6 -6
  15. data/acceptance/pre_suite/git/install.rb +22 -22
  16. data/acceptance/pre_suite/pkg/install.rb +3 -3
  17. data/acceptance/tests/backwards_compatible.rb +6 -7
  18. data/acceptance/tests/clone_git_repo_on_test.rb +12 -13
  19. data/acceptance/tests/create_tmpdir_on_test.rb +13 -9
  20. data/acceptance/tests/install_smoke_test.rb +5 -4
  21. data/acceptance/tests/stub_host.rb +11 -10
  22. data/acceptance/tests/web_helpers_test.rb +11 -10
  23. data/beaker-puppet.gemspec +16 -23
  24. data/bin/beaker-puppet +2 -4
  25. data/lib/beaker-puppet/helpers/facter_helpers.rb +9 -7
  26. data/lib/beaker-puppet/helpers/host_helpers.rb +10 -7
  27. data/lib/beaker-puppet/helpers/puppet_helpers.rb +151 -160
  28. data/lib/beaker-puppet/helpers/rake_helpers.rb +1 -1
  29. data/lib/beaker-puppet/helpers/tk_helpers.rb +22 -28
  30. data/lib/beaker-puppet/install_utils/aio_defaults.rb +39 -43
  31. data/lib/beaker-puppet/install_utils/ezbake_utils.rb +34 -42
  32. data/lib/beaker-puppet/install_utils/foss_defaults.rb +134 -138
  33. data/lib/beaker-puppet/install_utils/foss_utils.rb +293 -320
  34. data/lib/beaker-puppet/install_utils/module_utils.rb +58 -70
  35. data/lib/beaker-puppet/install_utils/puppet5.rb +30 -35
  36. data/lib/beaker-puppet/install_utils/puppet_utils.rb +58 -68
  37. data/lib/beaker-puppet/install_utils/windows_utils.rb +34 -36
  38. data/lib/beaker-puppet/version.rb +1 -1
  39. data/lib/beaker-puppet/wrappers.rb +13 -14
  40. data/lib/beaker-puppet.rb +4 -5
  41. data/setup/aio/010_Install_Puppet_Agent.rb +5 -6
  42. data/setup/common/000-delete-puppet-when-none.rb +2 -4
  43. data/setup/common/003_solaris_cert_fix.rb +74 -70
  44. data/setup/common/005_redhat_subscription_fix.rb +3 -2
  45. data/setup/common/011_Install_Puppet_Server.rb +7 -9
  46. data/setup/common/012_Finalize_Installs.rb +5 -5
  47. data/setup/common/025_StopFirewall.rb +1 -1
  48. data/setup/common/030_StopSssd.rb +2 -2
  49. data/setup/common/040_ValidateSignCert.rb +10 -12
  50. data/setup/common/045_EnsureMasterStarted.rb +2 -2
  51. data/setup/gem/010_GemInstall.rb +5 -4
  52. data/setup/git/000_EnvSetup.rb +48 -48
  53. data/setup/git/010_TestSetup.rb +13 -12
  54. data/setup/git/020_PuppetUserAndGroup.rb +3 -2
  55. data/setup/git/060_InstallModules.rb +14 -14
  56. data/setup/git/070_InstallCACerts.rb +82 -82
  57. data/spec/beaker-puppet/helpers/facter_helpers_spec.rb +22 -24
  58. data/spec/beaker-puppet/helpers/host_helpers_spec.rb +10 -6
  59. data/spec/beaker-puppet/helpers/puppet_helpers_spec.rb +506 -517
  60. data/spec/beaker-puppet/helpers/tk_helpers_spec.rb +20 -24
  61. data/spec/beaker-puppet/install_utils/ezbake_utils_spec.rb +86 -90
  62. data/spec/beaker-puppet/install_utils/foss_utils_spec.rb +636 -599
  63. data/spec/beaker-puppet/install_utils/module_utils_spec.rb +125 -116
  64. data/spec/beaker-puppet/install_utils/puppet5_spec.rb +159 -165
  65. data/spec/beaker-puppet/install_utils/puppet_utils_spec.rb +92 -77
  66. data/spec/beaker-puppet/install_utils/windows_utils_spec.rb +101 -89
  67. data/spec/beaker-puppet/wrappers_spec.rb +10 -10
  68. data/spec/helpers.rb +85 -91
  69. data/tasks/ci.rake +171 -179
  70. metadata +33 -62
  71. data/setup/common/020_InstallCumulusModules.rb +0 -13
  72. data/setup/common/021_InstallAristaModuleMasters.rb +0 -12
  73. data/setup/common/022_InstallAristaModuleAgents.rb +0 -13
@@ -11,88 +11,87 @@ class ClassMixedWithDSLHelpers
11
11
  def logger
12
12
  RSpec::Mocks::Double.new('logger').as_null_object
13
13
  end
14
-
15
14
  end
16
15
 
17
16
  describe ClassMixedWithDSLHelpers do
18
- let( :opts ) { Beaker::Options::Presets.env_vars }
19
- let( :command ){ 'ls' }
20
- let( :host ) { double.as_null_object }
21
- let( :result ) { Beaker::Result.new( host, command ) }
22
-
23
- let( :master ) { make_host( 'master', :roles => %w( master agent default) ) }
24
- let( :agent ) { make_host( 'agent', :roles => %w( agent ) ) }
25
- let( :custom ) { make_host( 'custom', :roles => %w( custom agent ) ) }
26
- let( :dash ) { make_host( 'console', :roles => %w( dashboard agent ) ) }
27
- let( :db ) { make_host( 'db', :roles => %w( database agent ) ) }
28
- let( :hosts ) { [ master, agent, dash, db, custom ] }
17
+ let(:opts) { Beaker::Options::Presets.env_vars }
18
+ let(:command) { 'ls' }
19
+ let(:host) { double.as_null_object }
20
+ let(:result) { Beaker::Result.new(host, command) }
21
+
22
+ let(:master) { make_host('master', roles: %w[master agent default]) }
23
+ let(:agent) { make_host('agent', roles: %w[agent]) }
24
+ let(:custom) { make_host('custom', roles: %w[custom agent]) }
25
+ let(:dash) { make_host('console', roles: %w[dashboard agent]) }
26
+ let(:db) { make_host('db', roles: %w[database agent]) }
27
+ let(:hosts) { [master, agent, dash, db, custom] }
29
28
 
30
29
  describe '#create_tmpdir_on' do
31
- let(:host) { {'user' => 'puppet', 'group' => 'muppets'} }
30
+ let(:host) { { 'user' => 'puppet', 'group' => 'muppets' } }
32
31
  let(:result_success) { double.as_null_object }
33
32
  let(:result_failure) { double.as_null_object }
34
33
  let(:tmpdir) { '/tmp/beaker.XXXXXX/' }
35
34
 
36
35
  before :each do
37
- allow( host ).to receive( :tmpdir ).and_return( tmpdir )
38
- allow( host ).to receive( :result ).and_return( result_success )
39
- allow( result_success ).to receive( :success? ).and_return( true )
40
- allow( result_success ).to receive( :stdout ).and_return( 'puppet' )
41
- allow( result_failure ).to receive( :success? ).and_return( false )
36
+ allow(host).to receive(:tmpdir).and_return(tmpdir)
37
+ allow(host).to receive(:result).and_return(result_success)
38
+ allow(result_success).to receive(:success?).and_return(true)
39
+ allow(result_success).to receive(:stdout).and_return('puppet')
40
+ allow(result_failure).to receive(:success?).and_return(false)
42
41
  end
43
42
 
44
43
  context 'with the path_prefix argument' do
45
44
  it 'passes path_prefix to host.tmpdir' do
46
- expect( host ).to receive( :tmpdir ).with( 'beaker' )
47
- subject.create_tmpdir_on( host, 'beaker' )
45
+ expect(host).to receive(:tmpdir).with('beaker')
46
+ subject.create_tmpdir_on(host, 'beaker')
48
47
  end
49
48
  end
50
49
 
51
50
  context 'with the user argument' do
52
51
  it 'calls chown when a user is specified' do
53
- expect( host ).to receive( :user_get ).and_return( result_success )
54
- expect( host ).to receive( :chown ).with( host['user'], tmpdir )
52
+ expect(host).to receive(:user_get).and_return(result_success)
53
+ expect(host).to receive(:chown).with(host['user'], tmpdir)
55
54
 
56
- subject.create_tmpdir_on( host, 'beaker', host['user'] )
55
+ subject.create_tmpdir_on(host, 'beaker', host['user'])
57
56
  end
58
57
 
59
58
  it 'does not call chown when a user is not specified' do
60
- expect( host ).to_not receive( :chown )
59
+ expect(host).to_not receive(:chown)
61
60
 
62
- subject.create_tmpdir_on( host, 'beaker' )
61
+ subject.create_tmpdir_on(host, 'beaker')
63
62
  end
64
63
 
65
64
  it 'does not call chown and cleans up when the user does not exist on the host' do
66
- expect( host ).to receive( :user_get ).and_return( result_failure )
67
- expect( host ).to receive( :rm_rf ).with( tmpdir )
65
+ expect(host).to receive(:user_get).and_return(result_failure)
66
+ expect(host).to receive(:rm_rf).with(tmpdir)
68
67
 
69
- expect{
70
- subject.create_tmpdir_on( host, 'beaker', 'invalid.user' )
71
- }.to raise_error( RuntimeError, /User invalid.user does not exist on / )
68
+ expect do
69
+ subject.create_tmpdir_on(host, 'beaker', 'invalid.user')
70
+ end.to raise_error(RuntimeError, /User invalid.user does not exist on /)
72
71
  end
73
72
  end
74
73
 
75
74
  context 'with the group argument' do
76
75
  it 'calls chgrp when a group is specified' do
77
- expect( host ).to receive( :group_get ).and_return( result_success )
78
- expect( host ).to receive( :chgrp ).with( host['group'], tmpdir )
76
+ expect(host).to receive(:group_get).and_return(result_success)
77
+ expect(host).to receive(:chgrp).with(host['group'], tmpdir)
79
78
 
80
- subject.create_tmpdir_on( host, 'beaker', nil, host['group'] )
79
+ subject.create_tmpdir_on(host, 'beaker', nil, host['group'])
81
80
  end
82
81
 
83
82
  it 'does not call chgrp when a group is not specified' do
84
- expect( subject ).to_not receive( :chgrp )
83
+ expect(subject).to_not receive(:chgrp)
85
84
 
86
- subject.create_tmpdir_on( host, 'beaker' )
85
+ subject.create_tmpdir_on(host, 'beaker')
87
86
  end
88
87
 
89
88
  it 'does not call chgrp and cleans up when the group does not exist on the host' do
90
- expect( host ).to receive( :group_get ).and_return( result_failure )
91
- expect( host ).to receive( :rm_rf ).with( tmpdir )
89
+ expect(host).to receive(:group_get).and_return(result_failure)
90
+ expect(host).to receive(:rm_rf).with(tmpdir)
92
91
 
93
- expect{
94
- subject.create_tmpdir_on( host, 'beaker', nil, 'invalid.group' )
95
- }.to raise_error( RuntimeError, /Group invalid.group does not exist on / )
92
+ expect do
93
+ subject.create_tmpdir_on(host, 'beaker', nil, 'invalid.group')
94
+ end.to raise_error(RuntimeError, /Group invalid.group does not exist on /)
96
95
  end
97
96
  end
98
97
 
@@ -100,22 +99,22 @@ describe ClassMixedWithDSLHelpers do
100
99
  # don't coalesce the group into chown, i.e. `chown user:group`
101
100
  # this keeps execution paths simple, clean, and discrete
102
101
  it 'calls chown and chgrp separately' do
103
- expect( host ).to receive( :user_get ).and_return( result_success )
104
- expect( host ).to receive( :group_get ).and_return( result_success )
105
- expect( host ).to receive( :chown ).with( host['user'], tmpdir )
106
- expect( host ).to receive( :chgrp ).with( host['group'], tmpdir )
102
+ expect(host).to receive(:user_get).and_return(result_success)
103
+ expect(host).to receive(:group_get).and_return(result_success)
104
+ expect(host).to receive(:chown).with(host['user'], tmpdir)
105
+ expect(host).to receive(:chgrp).with(host['group'], tmpdir)
107
106
 
108
- subject.create_tmpdir_on( host, 'beaker', host['user'], host['group'] )
107
+ subject.create_tmpdir_on(host, 'beaker', host['user'], host['group'])
109
108
  end
110
109
 
111
110
  it 'does not pass group to chown' do
112
- allow( host ).to receive( :user_get ).and_return( result_success )
113
- allow( host ).to receive( :chgrp ).with( host['group'], tmpdir )
111
+ allow(host).to receive(:user_get).and_return(result_success)
112
+ allow(host).to receive(:chgrp).with(host['group'], tmpdir)
114
113
 
115
- expect( host ).to receive( :group_get ).and_return( result_success )
116
- expect( host ).to receive( :chown ).with( host['user'], tmpdir )
114
+ expect(host).to receive(:group_get).and_return(result_success)
115
+ expect(host).to receive(:chown).with(host['user'], tmpdir)
117
116
 
118
- subject.create_tmpdir_on( host, 'beaker', host['user'], host['group'] )
117
+ subject.create_tmpdir_on(host, 'beaker', host['user'], host['group'])
119
118
  end
120
119
  end
121
120
  end
@@ -131,68 +130,65 @@ describe ClassMixedWithDSLHelpers do
131
130
  end
132
131
 
133
132
  context 'with no user argument' do
134
-
135
133
  context 'with no path name argument' do
136
134
  it 'executes chown once' do
137
- cmd = "the command"
138
- expect(Beaker::Command).to receive(:new).with(/puppet config print user --section master/, [], {"ENV"=>{}, :cmdexe=>true}).and_return(cmd)
135
+ cmd = 'the command'
136
+ expect(Beaker::Command).to receive(:new).with(/puppet config print user --section master/, [],
137
+ { 'ENV' => {}, :cmdexe => true }).and_return(cmd)
139
138
  expect(subject).to receive(:on).with(host, cmd).and_return(result)
140
- expect(subject).to receive(:create_tmpdir_on).with(host, /\/tmp\/beaker/, /puppet/)
139
+ expect(subject).to receive(:create_tmpdir_on).with(host, %r{/tmp/beaker}, /puppet/)
141
140
  subject.create_tmpdir_for_user(host)
142
141
  end
143
142
  end
144
143
 
145
144
  context 'with path name argument' do
146
145
  it 'executes chown once' do
147
- cmd = "the command"
148
- expect(Beaker::Command).to receive(:new).with(/puppet config print user --section master/, [], {"ENV"=>{}, :cmdexe=>true}).and_return(cmd)
146
+ cmd = 'the command'
147
+ expect(Beaker::Command).to receive(:new).with(/puppet config print user --section master/, [],
148
+ { 'ENV' => {}, :cmdexe => true }).and_return(cmd)
149
149
  expect(subject).to receive(:on).with(host, cmd).and_return(result)
150
- expect(subject).to receive(:create_tmpdir_on).with(host, /\/tmp\/bogus/, /puppet/)
151
- subject.create_tmpdir_for_user(host, "/tmp/bogus")
150
+ expect(subject).to receive(:create_tmpdir_on).with(host, %r{/tmp/bogus}, /puppet/)
151
+ subject.create_tmpdir_for_user(host, '/tmp/bogus')
152
152
  end
153
153
  end
154
-
155
154
  end
156
-
157
155
  end
158
156
 
159
-
160
157
  describe '#apply_manifest_on' do
161
-
162
158
  before :each do
163
159
  hosts.each do |host|
164
- allow( host ).to receive( :tmpfile )
160
+ allow(host).to receive(:tmpfile)
165
161
  end
166
162
  end
167
163
 
168
164
  it 'calls puppet' do
169
- allow( subject ).to receive( :hosts ).and_return( hosts )
170
- expect( subject ).to receive( :create_remote_file ).and_return( true )
171
- expect( subject ).to receive( :puppet ).
172
- # with( 'apply', '--verbose', 'agent' ).
173
- and_return( 'puppet_command' )
165
+ allow(subject).to receive(:hosts).and_return(hosts)
166
+ expect(subject).to receive(:create_remote_file).and_return(true)
167
+ expect(subject).to receive(:puppet).
168
+ # with( 'apply', '--verbose', 'agent' ).
169
+ and_return('puppet_command')
174
170
 
175
- expect( subject ).to receive( :on ).
176
- with( agent, 'puppet_command',
177
- {:acceptable_exit_codes => [0]} )
171
+ expect(subject).to receive(:on)
172
+ .with(agent, 'puppet_command',
173
+ { acceptable_exit_codes: [0] })
178
174
 
179
- subject.apply_manifest_on( agent, 'class { "boo": }')
175
+ subject.apply_manifest_on(agent, 'class { "boo": }')
180
176
  end
181
177
 
182
178
  it 'operates on an array of hosts' do
183
- allow( subject ).to receive( :hosts ).and_return( hosts )
179
+ allow(subject).to receive(:hosts).and_return(hosts)
184
180
  the_hosts = [master, agent]
185
181
 
186
- expect( subject ).to receive( :create_remote_file ).twice.and_return( true )
182
+ expect(subject).to receive(:create_remote_file).twice.and_return(true)
187
183
  the_hosts.each do |host|
188
- expect( subject ).to receive( :puppet ).
189
- and_return( 'puppet_command' )
184
+ expect(subject).to receive(:puppet)
185
+ .and_return('puppet_command')
190
186
 
191
- expect( subject ).to receive( :on ).
192
- with( host, 'puppet_command', {:acceptable_exit_codes => [0]} )
187
+ expect(subject).to receive(:on)
188
+ .with(host, 'puppet_command', { acceptable_exit_codes: [0] })
193
189
  end
194
190
 
195
- result = subject.apply_manifest_on( the_hosts, 'include foobar' )
191
+ result = subject.apply_manifest_on(the_hosts, 'include foobar')
196
192
  expect(result).to be_an(Array)
197
193
  end
198
194
 
@@ -201,536 +197,534 @@ describe ClassMixedWithDSLHelpers do
201
197
  FakeFS.deactivate!
202
198
  # This will only get hit if forking processes is supported and at least 2 items are being submitted to run in parallel
203
199
  # expect( InParallel::InParallelExecutor ).to receive(:_execute_in_parallel).with(any_args).and_call_original.exactly(2).times
204
- allow( subject ).to receive( :hosts ).and_return( hosts )
200
+ allow(subject).to receive(:hosts).and_return(hosts)
205
201
  the_hosts = [master, agent]
206
202
 
207
- allow( subject ).to receive( :create_remote_file ).and_return( true )
208
- allow( subject ).to receive( :puppet ).
209
- and_return( 'puppet_command' )
203
+ allow(subject).to receive(:create_remote_file).and_return(true)
204
+ allow(subject).to receive(:puppet)
205
+ .and_return('puppet_command')
210
206
  the_hosts.each do |host|
211
- allow( subject ).to receive( :on ).
212
- with( host, 'puppet_command', {:acceptable_exit_codes => [0]} )
207
+ allow(subject).to receive(:on)
208
+ .with(host, 'puppet_command', { acceptable_exit_codes: [0] })
213
209
  end
214
210
 
215
211
  result = nil
216
- result = subject.apply_manifest_on( the_hosts, 'include foobar' )
212
+ result = subject.apply_manifest_on(the_hosts, 'include foobar')
217
213
  expect(result).to be_an(Array)
218
214
  end
219
215
 
220
216
  it 'runs block_on in parallel if set' do
221
217
  InParallel::InParallelExecutor.logger = logger
222
218
  FakeFS.deactivate!
223
- allow( subject ).to receive( :hosts ).and_return( hosts )
219
+ allow(subject).to receive(:hosts).and_return(hosts)
224
220
  the_hosts = [master, agent]
225
221
 
226
- allow( subject ).to receive( :create_remote_file ).and_return( true )
227
- allow( subject ).to receive( :puppet ).
228
- and_return( 'puppet_command' )
222
+ allow(subject).to receive(:create_remote_file).and_return(true)
223
+ allow(subject).to receive(:puppet)
224
+ .and_return('puppet_command')
229
225
  the_hosts.each do |host|
230
- allow( subject ).to receive( :on ).
231
- with( host, 'puppet_command', {:acceptable_exit_codes => [0]} )
226
+ allow(subject).to receive(:on)
227
+ .with(host, 'puppet_command', { acceptable_exit_codes: [0] })
232
228
  end
233
- expect( subject ).to receive( :block_on ).with(
229
+ expect(subject).to receive(:block_on).with(
234
230
  anything,
235
- {:run_in_parallel => true}
231
+ { run_in_parallel: true },
236
232
  )
237
233
 
238
- subject.apply_manifest_on( the_hosts, 'include foobar', { :run_in_parallel => true } )
234
+ subject.apply_manifest_on(the_hosts, 'include foobar', { run_in_parallel: true })
239
235
  end
240
236
 
241
237
  it 'adds acceptable exit codes with :catch_failures' do
242
- allow( subject ).to receive( :hosts ).and_return( hosts )
243
- expect( subject ).to receive( :create_remote_file ).and_return( true )
244
- expect( subject ).to receive( :puppet ).
245
- and_return( 'puppet_command' )
238
+ allow(subject).to receive(:hosts).and_return(hosts)
239
+ expect(subject).to receive(:create_remote_file).and_return(true)
240
+ expect(subject).to receive(:puppet)
241
+ .and_return('puppet_command')
246
242
 
247
- expect( subject ).to receive( :on ).
248
- with( agent, 'puppet_command',
249
- {:acceptable_exit_codes => [0,2]} )
243
+ expect(subject).to receive(:on)
244
+ .with(agent, 'puppet_command',
245
+ { acceptable_exit_codes: [0, 2] })
250
246
 
251
- subject.apply_manifest_on( agent,
247
+ subject.apply_manifest_on(agent,
252
248
  'class { "boo": }',
253
- {:catch_failures => true} )
249
+ { catch_failures: true })
254
250
  end
255
251
  it 'allows acceptable exit codes through :catch_failures' do
256
- allow( subject ).to receive( :hosts ).and_return( hosts )
257
- expect( subject ).to receive( :create_remote_file ).and_return( true )
258
- expect( subject ).to receive( :puppet ).
259
- and_return( 'puppet_command' )
252
+ allow(subject).to receive(:hosts).and_return(hosts)
253
+ expect(subject).to receive(:create_remote_file).and_return(true)
254
+ expect(subject).to receive(:puppet)
255
+ .and_return('puppet_command')
260
256
 
261
- expect( subject ).to receive( :on ).
262
- with( agent, 'puppet_command',
263
- {:acceptable_exit_codes => [4,0,2]} )
257
+ expect(subject).to receive(:on)
258
+ .with(agent, 'puppet_command',
259
+ { acceptable_exit_codes: [4, 0, 2] })
264
260
 
265
- subject.apply_manifest_on( agent,
261
+ subject.apply_manifest_on(agent,
266
262
  'class { "boo": }',
267
- {:acceptable_exit_codes => [4],
268
- :catch_failures => true} )
263
+ { acceptable_exit_codes: [4],
264
+ catch_failures: true, })
269
265
  end
270
266
  it 'enforces a 0 exit code through :catch_changes' do
271
- allow( subject ).to receive( :hosts ).and_return( hosts )
272
- expect( subject ).to receive( :create_remote_file ).and_return( true )
273
- expect( subject ).to receive( :puppet ).
274
- and_return( 'puppet_command' )
267
+ allow(subject).to receive(:hosts).and_return(hosts)
268
+ expect(subject).to receive(:create_remote_file).and_return(true)
269
+ expect(subject).to receive(:puppet)
270
+ .and_return('puppet_command')
275
271
 
276
- expect( subject ).to receive( :on ).with(
272
+ expect(subject).to receive(:on).with(
277
273
  agent,
278
274
  'puppet_command',
279
- {:acceptable_exit_codes => [0]}
275
+ { acceptable_exit_codes: [0] },
280
276
  )
281
277
 
282
278
  subject.apply_manifest_on(
283
279
  agent,
284
280
  'class { "boo": }',
285
- {:catch_changes => true}
281
+ { catch_changes: true },
286
282
  )
287
283
  end
288
284
  it 'enforces a 2 exit code through :expect_changes' do
289
- allow( subject ).to receive( :hosts ).and_return( hosts )
290
- expect( subject ).to receive( :create_remote_file ).and_return( true )
291
- expect( subject ).to receive( :puppet ).
292
- and_return( 'puppet_command' )
285
+ allow(subject).to receive(:hosts).and_return(hosts)
286
+ expect(subject).to receive(:create_remote_file).and_return(true)
287
+ expect(subject).to receive(:puppet)
288
+ .and_return('puppet_command')
293
289
 
294
- expect( subject ).to receive( :on ).with(
290
+ expect(subject).to receive(:on).with(
295
291
  agent,
296
292
  'puppet_command',
297
- {:acceptable_exit_codes => [2]}
293
+ { acceptable_exit_codes: [2] },
298
294
  )
299
295
 
300
296
  subject.apply_manifest_on(
301
297
  agent,
302
298
  'class { "boo": }',
303
- {:expect_changes => true}
299
+ { expect_changes: true },
304
300
  )
305
301
  end
306
302
  it 'enforces exit codes through :expect_failures' do
307
- allow( subject ).to receive( :hosts ).and_return( hosts )
308
- expect( subject ).to receive( :create_remote_file ).and_return( true )
309
- expect( subject ).to receive( :puppet ).
310
- and_return( 'puppet_command' )
303
+ allow(subject).to receive(:hosts).and_return(hosts)
304
+ expect(subject).to receive(:create_remote_file).and_return(true)
305
+ expect(subject).to receive(:puppet)
306
+ .and_return('puppet_command')
311
307
 
312
- expect( subject ).to receive( :on ).with(
308
+ expect(subject).to receive(:on).with(
313
309
  agent,
314
310
  'puppet_command',
315
- {:acceptable_exit_codes => [1,4,6]}
311
+ { acceptable_exit_codes: [1, 4, 6] },
316
312
  )
317
313
 
318
314
  subject.apply_manifest_on(
319
315
  agent,
320
316
  'class { "boo": }',
321
- {:expect_failures => true}
317
+ { expect_failures: true },
322
318
  )
323
319
  end
324
320
  it 'enforces exit codes through :expect_failures' do
325
- allow( subject ).to receive( :hosts ).and_return( hosts )
326
- expect {
321
+ allow(subject).to receive(:hosts).and_return(hosts)
322
+ expect do
327
323
  subject.apply_manifest_on(
328
324
  agent,
329
325
  'class { "boo": }',
330
- :expect_failures => true,
331
- :catch_failures => true
326
+ expect_failures: true,
327
+ catch_failures: true,
332
328
  )
333
- }.to raise_error ArgumentError, /catch_failures.+expect_failures/
329
+ end.to raise_error ArgumentError, /catch_failures.+expect_failures/
334
330
  end
335
331
  it 'enforces added exit codes through :expect_failures' do
336
- allow( subject ).to receive( :hosts ).and_return( hosts )
337
- expect( subject ).to receive( :create_remote_file ).and_return( true )
338
- expect( subject ).to receive( :puppet ).
339
- and_return( 'puppet_command' )
332
+ allow(subject).to receive(:hosts).and_return(hosts)
333
+ expect(subject).to receive(:create_remote_file).and_return(true)
334
+ expect(subject).to receive(:puppet)
335
+ .and_return('puppet_command')
340
336
 
341
- expect( subject ).to receive( :on ).with(
337
+ expect(subject).to receive(:on).with(
342
338
  agent,
343
339
  'puppet_command',
344
- {:acceptable_exit_codes => [1,2,3,4,5,6]}
340
+ { acceptable_exit_codes: [1, 2, 3, 4, 5, 6] },
345
341
  )
346
342
 
347
343
  subject.apply_manifest_on(
348
344
  agent,
349
345
  'class { "boo": }',
350
- {:acceptable_exit_codes => (1..5),
351
- :expect_failures => true}
346
+ { acceptable_exit_codes: (1..5),
347
+ expect_failures: true, },
352
348
  )
353
349
  end
354
350
 
355
351
  it 'can set the --parser future flag' do
356
- allow( subject ).to receive( :hosts ).and_return( hosts )
357
- expect( subject ).to receive( :create_remote_file ).and_return( true )
352
+ allow(subject).to receive(:hosts).and_return(hosts)
353
+ expect(subject).to receive(:create_remote_file).and_return(true)
358
354
 
359
- expect( subject ).to receive( :puppet ).with(
355
+ expect(subject).to receive(:puppet).with(
360
356
  'apply',
361
357
  anything,
362
358
  include(
363
359
  :parser => 'future',
364
360
  'detailed-exitcodes' => nil,
365
- :verbose => nil
366
- )
361
+ :verbose => nil,
362
+ ),
367
363
  )
368
364
 
369
- allow( subject ).to receive( :on )
365
+ allow(subject).to receive(:on)
370
366
  hosts.each do |host|
371
- allow( host ).to receive( :tmpfile ).and_return( 'pants' )
367
+ allow(host).to receive(:tmpfile).and_return('pants')
372
368
  end
373
369
 
374
370
  subject.apply_manifest_on(
375
371
  agent,
376
372
  'class { "boo": }',
377
- :acceptable_exit_codes => (1..5),
378
- :future_parser => true,
379
- :expect_failures => true
373
+ acceptable_exit_codes: (1..5),
374
+ future_parser: true,
375
+ expect_failures: true,
380
376
  )
381
377
  end
382
378
 
383
379
  it 'can set the --noops flag' do
384
- allow( subject ).to receive( :hosts ).and_return( hosts )
385
- expect( subject ).to receive( :create_remote_file ).and_return( true )
380
+ allow(subject).to receive(:hosts).and_return(hosts)
381
+ expect(subject).to receive(:create_remote_file).and_return(true)
386
382
 
387
- expect( subject ).to receive( :puppet ).with(
383
+ expect(subject).to receive(:puppet).with(
388
384
  'apply',
389
385
  anything,
390
386
  include(
391
387
  :noop => nil,
392
388
  'detailed-exitcodes' => nil,
393
- :verbose => nil
394
- )
389
+ :verbose => nil,
390
+ ),
395
391
  )
396
392
 
397
- allow( subject ).to receive( :on )
393
+ allow(subject).to receive(:on)
398
394
  hosts.each do |host|
399
- allow( host ).to receive( :tmpfile ).and_return( 'pants' )
395
+ allow(host).to receive(:tmpfile).and_return('pants')
400
396
  end
401
397
 
402
398
  subject.apply_manifest_on(
403
399
  agent,
404
400
  'class { "boo": }',
405
- :acceptable_exit_codes => (1..5),
406
- :noop => true,
407
- :expect_failures => true
401
+ acceptable_exit_codes: (1..5),
402
+ noop: true,
403
+ expect_failures: true,
408
404
  )
409
405
  end
410
406
  end
411
407
 
412
408
  it 'can set the --debug flag' do
413
- allow( subject ).to receive( :hosts ).and_return( hosts )
414
- allow( subject ).to receive( :create_remote_file ).and_return( true )
415
- allow( agent ).to receive( :tmpfile )
416
- allow( subject ).to receive( :on )
409
+ allow(subject).to receive(:hosts).and_return(hosts)
410
+ allow(subject).to receive(:create_remote_file).and_return(true)
411
+ allow(agent).to receive(:tmpfile)
412
+ allow(subject).to receive(:on)
417
413
 
418
- expect( subject ).to receive( :puppet ).with(
414
+ expect(subject).to receive(:puppet).with(
419
415
  'apply',
420
416
  anything,
421
- include( :debug => nil )
417
+ include(debug: nil),
422
418
  )
423
419
 
424
420
  subject.apply_manifest_on(
425
421
  agent,
426
422
  'class { "boo": }',
427
- :debug => true,
423
+ debug: true,
428
424
  )
429
425
  end
430
426
 
431
- describe "#apply_manifest" do
432
- it "delegates to #apply_manifest_on with the default host" do
433
- allow( subject ).to receive( :hosts ).and_return( hosts )
427
+ describe '#apply_manifest' do
428
+ it 'delegates to #apply_manifest_on with the default host' do
429
+ allow(subject).to receive(:hosts).and_return(hosts)
434
430
  # allow( subject ).to receive( :default ).and_return( master )
435
431
 
436
- expect( subject ).to receive( :default ).and_return( master )
437
- expect( subject ).to receive( :apply_manifest_on ).with( master, 'manifest', {:opt => 'value'}).once
438
-
439
- subject.apply_manifest( 'manifest', {:opt => 'value'} )
432
+ expect(subject).to receive(:default).and_return(master)
433
+ expect(subject).to receive(:apply_manifest_on).with(master, 'manifest', { opt: 'value' }).once
440
434
 
435
+ subject.apply_manifest('manifest', { opt: 'value' })
441
436
  end
442
437
  end
443
438
 
444
439
  describe '#stub_hosts_on' do
445
440
  it 'executes puppet on the host passed and ensures it is reverted' do
446
441
  test_host = make_host('my_host', {})
447
- allow( subject ).to receive( :hosts ).and_return( hosts )
442
+ allow(subject).to receive(:hosts).and_return(hosts)
448
443
  logger = double.as_null_object
449
444
 
450
- expect( subject ).to receive( :on ).once
451
- allow( subject ).to receive( :logger ).and_return( logger )
452
- expect( subject ).to receive( :teardown ).and_yield
453
- manifest =<<-EOS.gsub /^\s+/, ""
445
+ expect(subject).to receive(:on).once
446
+ allow(subject).to receive(:logger).and_return(logger)
447
+ expect(subject).to receive(:teardown).and_yield
448
+ manifest = <<-EOS.gsub /^\s+/, ''
454
449
  host { 'puppetlabs.com':
455
450
  \tensure => present,
456
451
  \tip => '127.0.0.1',
457
452
  \thost_aliases => [],
458
453
  }
459
454
  EOS
460
- expect( subject ).to receive( :apply_manifest_on ).once.
461
- with( test_host, manifest )
462
- expect( subject ).to receive( :puppet ).once.
463
- with( 'resource', 'host',
464
- 'puppetlabs.com',
465
- 'ensure=absent' )
455
+ expect(subject).to receive(:apply_manifest_on).once
456
+ .with(test_host, manifest)
457
+ expect(subject).to receive(:puppet).once
458
+ .with('resource', 'host',
459
+ 'puppetlabs.com',
460
+ 'ensure=absent')
466
461
 
467
- subject.stub_hosts_on( test_host, {'puppetlabs.com' => '127.0.0.1'} )
462
+ subject.stub_hosts_on(test_host, { 'puppetlabs.com' => '127.0.0.1' })
468
463
  end
469
464
  it 'adds aliases to defined hostname' do
470
465
  test_host = make_host('my_host', {})
471
- allow( subject ).to receive( :hosts ).and_return( hosts )
466
+ allow(subject).to receive(:hosts).and_return(hosts)
472
467
  logger = double.as_null_object
473
468
 
474
- expect( subject ).to receive( :on ).once
475
- allow( subject ).to receive( :logger ).and_return( logger )
476
- expect( subject ).to receive( :teardown ).and_yield
477
- manifest =<<-EOS.gsub /^\s+/, ""
469
+ expect(subject).to receive(:on).once
470
+ allow(subject).to receive(:logger).and_return(logger)
471
+ expect(subject).to receive(:teardown).and_yield
472
+ manifest = <<-EOS.gsub /^\s+/, ''
478
473
  host { 'puppetlabs.com':
479
474
  \tensure => present,
480
475
  \tip => '127.0.0.1',
481
- \thost_aliases => [\"foo\", \"bar\"],
476
+ \thost_aliases => ["foo", "bar"],
482
477
  }
483
478
  EOS
484
- expect( subject ).to receive( :apply_manifest_on ).once.
485
- with( test_host, manifest )
479
+ expect(subject).to receive(:apply_manifest_on).once
480
+ .with(test_host, manifest)
486
481
 
487
- subject.stub_hosts_on( test_host, {'puppetlabs.com' => '127.0.0.1'}, {'puppetlabs.com' => ['foo','bar']} )
482
+ subject.stub_hosts_on(test_host, { 'puppetlabs.com' => '127.0.0.1' }, { 'puppetlabs.com' => %w[foo bar] })
488
483
  end
489
484
  end
490
485
 
491
- describe "#stub_hosts" do
492
- it "delegates to stub_hosts_on with the default host" do
493
- allow( subject ).to receive( :hosts ).and_return( hosts )
494
-
495
- expect( subject ).to receive( :default ).and_return( master )
496
- expect( subject ).to receive( :stub_hosts_on ).with( master, 'ipspec' ).once
486
+ describe '#stub_hosts' do
487
+ it 'delegates to stub_hosts_on with the default host' do
488
+ allow(subject).to receive(:hosts).and_return(hosts)
497
489
 
498
- subject.stub_hosts( 'ipspec' )
490
+ expect(subject).to receive(:default).and_return(master)
491
+ expect(subject).to receive(:stub_hosts_on).with(master, 'ipspec').once
499
492
 
493
+ subject.stub_hosts('ipspec')
500
494
  end
501
495
  end
502
496
 
503
497
  describe '#stub_forge_on' do
504
498
  it 'stubs forge.puppetlabs.com with the value of `forge`' do
505
- allow( subject ).to receive( :resolve_hostname_on ).and_return ( '127.0.0.1' )
499
+ allow(subject).to receive(:resolve_hostname_on).and_return ( '127.0.0.1')
506
500
  host = make_host('my_host', {})
507
- expect( subject ).to receive( :stub_hosts_on ).
508
- with( host, {'forge.puppetlabs.com' => '127.0.0.1'}, {'forge.puppetlabs.com' => ['forge.puppet.com','forgeapi.puppetlabs.com','forgeapi.puppet.com']} )
501
+ expect(subject).to receive(:stub_hosts_on)
502
+ .with(host, { 'forge.puppetlabs.com' => '127.0.0.1' }, { 'forge.puppetlabs.com' => ['forge.puppet.com',
503
+ 'forgeapi.puppetlabs.com', 'forgeapi.puppet.com',] })
509
504
 
510
- subject.stub_forge_on( host, 'my_forge.example.com' )
505
+ subject.stub_forge_on(host, 'my_forge.example.com')
511
506
  end
512
507
  end
513
508
 
514
- describe "#stub_forge" do
515
- it "delegates to stub_forge_on with the default host" do
516
- allow( subject ).to receive( :options ).and_return( {} )
517
- allow( subject ).to receive( :hosts ).and_return( hosts )
509
+ describe '#stub_forge' do
510
+ it 'delegates to stub_forge_on with the default host' do
511
+ allow(subject).to receive(:options).and_return({})
512
+ allow(subject).to receive(:hosts).and_return(hosts)
518
513
 
519
- expect( subject ).to receive( :default ).and_return( master )
520
- expect( subject ).to receive( :stub_forge_on ).with( master, nil ).once
521
-
522
- subject.stub_forge( )
514
+ expect(subject).to receive(:default).and_return(master)
515
+ expect(subject).to receive(:stub_forge_on).with(master, nil).once
523
516
 
517
+ subject.stub_forge
524
518
  end
525
519
  end
526
520
 
527
- describe "#stop_agent_on" do
528
- let( :result_fail ) { Beaker::Result.new( [], "" ) }
529
- let( :result_pass ) { Beaker::Result.new( [], "" ) }
521
+ describe '#stop_agent_on' do
522
+ let(:result_fail) { Beaker::Result.new([], '') }
523
+ let(:result_pass) { Beaker::Result.new([], '') }
530
524
  before :each do
531
- allow( subject ).to receive( :sleep ).and_return( true )
525
+ allow(subject).to receive(:sleep).and_return(true)
532
526
  end
533
527
 
534
528
  it 'runs the pe-puppet on a system without pe-puppet-agent' do
535
529
  vardir = '/var'
536
- deb_agent = make_host( 'deb', :platform => 'debian-7-amd64', :pe_ver => '3.7' )
537
- allow( deb_agent ).to receive( :puppet_configprint ).and_return( { 'vardir' => vardir } )
538
-
539
- expect( deb_agent ).to receive( :file_exist? ).with("/var/state/agent_catalog_run.lock").and_return(false)
540
- expect( deb_agent ).to receive( :file_exist? ).with("/etc/init.d/pe-puppet-agent").and_return(false)
530
+ deb_agent = make_host('deb', platform: 'debian-7-amd64', pe_ver: '3.7')
531
+ allow(deb_agent).to receive(:puppet_configprint).and_return({ 'vardir' => vardir })
541
532
 
542
- expect( subject ).to receive( :aio_version? ).with( deb_agent ).and_return( false )
543
- expect( subject ).to receive( :version_is_less ).with( deb_agent[:pe_ver], '3.2' ).and_return( false )
544
- expect( subject ).to receive( :puppet_resource ).with( "service", "pe-puppet", "ensure=stopped").once
545
- expect( subject ).to receive( :on ).once
533
+ expect(deb_agent).to receive(:file_exist?).with('/var/state/agent_catalog_run.lock').and_return(false)
534
+ expect(deb_agent).to receive(:file_exist?).with('/etc/init.d/pe-puppet-agent').and_return(false)
546
535
 
547
- subject.stop_agent_on( deb_agent )
536
+ expect(subject).to receive(:aio_version?).with(deb_agent).and_return(false)
537
+ expect(subject).to receive(:version_is_less).with(deb_agent[:pe_ver], '3.2').and_return(false)
538
+ expect(subject).to receive(:puppet_resource).with('service', 'pe-puppet', 'ensure=stopped').once
539
+ expect(subject).to receive(:on).once
548
540
 
541
+ subject.stop_agent_on(deb_agent)
549
542
  end
550
543
 
551
544
  it 'runs the pe-puppet-agent on a unix system with pe-puppet-agent' do
552
545
  vardir = '/var'
553
- el_agent = make_host( 'el', :platform => 'el-5-x86_64', :pe_ver => '3.7' )
554
- allow( el_agent ).to receive( :puppet_configprint ).and_return( { 'vardir' => vardir } )
546
+ el_agent = make_host('el', platform: 'el-5-x86_64', pe_ver: '3.7')
547
+ allow(el_agent).to receive(:puppet_configprint).and_return({ 'vardir' => vardir })
555
548
 
556
- expect( el_agent ).to receive( :file_exist? ).with("/var/state/agent_catalog_run.lock").and_return(false)
557
- expect( el_agent ).to receive( :file_exist? ).with("/etc/init.d/pe-puppet-agent").and_return(true)
549
+ expect(el_agent).to receive(:file_exist?).with('/var/state/agent_catalog_run.lock').and_return(false)
550
+ expect(el_agent).to receive(:file_exist?).with('/etc/init.d/pe-puppet-agent').and_return(true)
558
551
 
559
- expect( subject ).to receive( :aio_version? ).with( el_agent ).and_return( false )
560
- expect( subject ).to receive( :version_is_less ).with( el_agent[:pe_ver], '3.2' ).and_return( false )
561
- expect( subject ).to receive( :puppet_resource ).with( "service", "pe-puppet-agent", "ensure=stopped").once
562
- expect( subject ).to receive( :on ).once
552
+ expect(subject).to receive(:aio_version?).with(el_agent).and_return(false)
553
+ expect(subject).to receive(:version_is_less).with(el_agent[:pe_ver], '3.2').and_return(false)
554
+ expect(subject).to receive(:puppet_resource).with('service', 'pe-puppet-agent', 'ensure=stopped').once
555
+ expect(subject).to receive(:on).once
563
556
 
564
- subject.stop_agent_on( el_agent )
557
+ subject.stop_agent_on(el_agent)
565
558
  end
566
559
 
567
560
  it 'runs puppet on a unix system 4.0 or newer' do
568
561
  vardir = '/var'
569
- el_agent = make_host( 'el', :platform => 'el-5-x86_64', :pe_ver => '4.0' )
570
- allow( el_agent ).to receive( :puppet_configprint ).and_return( { 'vardir' => vardir } )
562
+ el_agent = make_host('el', platform: 'el-5-x86_64', pe_ver: '4.0')
563
+ allow(el_agent).to receive(:puppet_configprint).and_return({ 'vardir' => vardir })
571
564
 
572
- expect( el_agent ).to receive( :file_exist? ).with("/var/state/agent_catalog_run.lock").and_return(false)
565
+ expect(el_agent).to receive(:file_exist?).with('/var/state/agent_catalog_run.lock').and_return(false)
573
566
 
574
- expect( subject ).to receive( :aio_version? ).with( el_agent ).and_return( true )
575
- expect( subject ).to receive( :version_is_less ).with( el_agent[:pe_ver], '3.2' ).and_return( false )
576
- expect( subject ).to receive( :puppet_resource ).with( "service", "puppet", "ensure=stopped").once
577
- expect( subject ).to receive( :on ).once
567
+ expect(subject).to receive(:aio_version?).with(el_agent).and_return(true)
568
+ expect(subject).to receive(:version_is_less).with(el_agent[:pe_ver], '3.2').and_return(false)
569
+ expect(subject).to receive(:puppet_resource).with('service', 'puppet', 'ensure=stopped').once
570
+ expect(subject).to receive(:on).once
578
571
 
579
- subject.stop_agent_on( el_agent )
572
+ subject.stop_agent_on(el_agent)
580
573
  end
581
574
 
582
575
  it 'can run on an array of hosts' do
583
576
  vardir = '/var'
584
- el_agent = make_host( 'el', :platform => 'el-5-x86_64', :pe_ver => '4.0' )
585
- el_agent2 = make_host( 'el', :platform => 'el-5-x86_64', :pe_ver => '4.0' )
577
+ el_agent = make_host('el', platform: 'el-5-x86_64', pe_ver: '4.0')
578
+ el_agent2 = make_host('el', platform: 'el-5-x86_64', pe_ver: '4.0')
586
579
 
587
- allow( el_agent ).to receive( :puppet_configprint ).and_return( { 'vardir' => vardir } )
588
- expect( el_agent ).to receive( :file_exist? ).with("/var/state/agent_catalog_run.lock").and_return(false)
589
- expect( subject ).to receive( :aio_version? ).with( el_agent ).and_return( true )
590
- expect( subject ).to receive( :version_is_less ).with( el_agent[:pe_ver], '3.2' ).and_return( false )
580
+ allow(el_agent).to receive(:puppet_configprint).and_return({ 'vardir' => vardir })
581
+ expect(el_agent).to receive(:file_exist?).with('/var/state/agent_catalog_run.lock').and_return(false)
582
+ expect(subject).to receive(:aio_version?).with(el_agent).and_return(true)
583
+ expect(subject).to receive(:version_is_less).with(el_agent[:pe_ver], '3.2').and_return(false)
591
584
 
592
- allow( el_agent2 ).to receive( :puppet_configprint ).and_return( { 'vardir' => vardir } )
593
- expect( el_agent2 ).to receive( :file_exist? ).with("/var/state/agent_catalog_run.lock").and_return(false)
594
- expect( subject ).to receive( :aio_version? ).with( el_agent2 ).and_return( true )
595
- expect( subject ).to receive( :version_is_less ).with( el_agent2[:pe_ver], '3.2' ).and_return( false )
585
+ allow(el_agent2).to receive(:puppet_configprint).and_return({ 'vardir' => vardir })
586
+ expect(el_agent2).to receive(:file_exist?).with('/var/state/agent_catalog_run.lock').and_return(false)
587
+ expect(subject).to receive(:aio_version?).with(el_agent2).and_return(true)
588
+ expect(subject).to receive(:version_is_less).with(el_agent2[:pe_ver], '3.2').and_return(false)
596
589
 
597
- expect( subject ).to receive( :puppet_resource ).with( "service", "puppet", "ensure=stopped").twice
598
- expect( subject ).to receive( :on ).twice
590
+ expect(subject).to receive(:puppet_resource).with('service', 'puppet', 'ensure=stopped').twice
591
+ expect(subject).to receive(:on).twice
599
592
 
600
- subject.stop_agent_on( [el_agent, el_agent2] )
593
+ subject.stop_agent_on([el_agent, el_agent2])
601
594
  end
602
595
 
603
596
  it 'runs in parallel with run_in_parallel=true' do
604
597
  InParallel::InParallelExecutor.logger = logger
605
598
  FakeFS.deactivate!
606
599
  vardir = '/var'
607
- el_agent = make_host( 'el', :platform => 'el-5-x86_64', :pe_ver => '4.0' )
608
- el_agent2 = make_host( 'el', :platform => 'el-5-x86_64', :pe_ver => '4.0' )
600
+ el_agent = make_host('el', platform: 'el-5-x86_64', pe_ver: '4.0')
601
+ el_agent2 = make_host('el', platform: 'el-5-x86_64', pe_ver: '4.0')
609
602
 
610
- allow( el_agent ).to receive( :puppet_configprint ).and_return( { 'vardir' => vardir } )
611
- allow( el_agent ).to receive( :file_exist? ).with("/var/state/agent_catalog_run.lock").and_return(false)
603
+ allow(el_agent).to receive(:puppet_configprint).and_return({ 'vardir' => vardir })
604
+ allow(el_agent).to receive(:file_exist?).with('/var/state/agent_catalog_run.lock').and_return(false)
612
605
 
613
- allow( el_agent2 ).to receive( :puppet_configprint ).and_return( { 'vardir' => vardir } )
614
- allow( el_agent2 ).to receive( :file_exist? ).with("/var/state/agent_catalog_run.lock").and_return(false)
606
+ allow(el_agent2).to receive(:puppet_configprint).and_return({ 'vardir' => vardir })
607
+ allow(el_agent2).to receive(:file_exist?).with('/var/state/agent_catalog_run.lock').and_return(false)
615
608
 
616
609
  # This will only get hit if forking processes is supported and at least 2 items are being submitted to run in parallel
617
- expect( subject ).to receive( :block_on ).with(
610
+ expect(subject).to receive(:block_on).with(
618
611
  anything,
619
- include( :run_in_parallel => true )
612
+ include(run_in_parallel: true),
620
613
  )
621
614
 
622
- subject.stop_agent_on( [el_agent, el_agent2], { :run_in_parallel => true} )
615
+ subject.stop_agent_on([el_agent, el_agent2], { run_in_parallel: true })
623
616
  end
624
-
625
617
  end
626
618
 
627
- describe "#stop_agent" do
619
+ describe '#stop_agent' do
628
620
  it 'delegates to #stop_agent_on with default host' do
629
- allow( subject ).to receive( :hosts ).and_return( hosts )
621
+ allow(subject).to receive(:hosts).and_return(hosts)
630
622
 
631
- expect( subject ).to receive( :default ).and_return( master )
632
- expect( subject ).to receive( :stop_agent_on ).with( master ).once
633
-
634
- subject.stop_agent( )
623
+ expect(subject).to receive(:default).and_return(master)
624
+ expect(subject).to receive(:stop_agent_on).with(master).once
635
625
 
626
+ subject.stop_agent
636
627
  end
637
628
  end
638
629
 
639
- describe "#sign_certificate_for" do
640
-
630
+ describe '#sign_certificate_for' do
641
631
  before :each do
642
- allow( subject ).to receive( :hosts ).and_return( hosts )
643
- allow( subject ).to receive( :master ).and_return( master )
644
- allow( subject ).to receive( :dashboard ).and_return( dash )
645
- allow( subject ).to receive( :database ).and_return( db )
632
+ allow(subject).to receive(:hosts).and_return(hosts)
633
+ allow(subject).to receive(:master).and_return(master)
634
+ allow(subject).to receive(:dashboard).and_return(dash)
635
+ allow(subject).to receive(:database).and_return(db)
646
636
  hosts.each do |host|
647
- allow( host ).to receive( :node_name ).and_return( '' )
637
+ allow(host).to receive(:node_name).and_return('')
648
638
  end
649
639
  end
650
640
 
651
641
  it 'signs certs with `puppetserver ca` in Puppet 6' do
652
- allow( subject ).to receive( :sleep ).and_return( true )
642
+ allow(subject).to receive(:sleep).and_return(true)
653
643
 
654
644
  result.stdout = "+ \"#{agent}\""
655
645
 
656
- allow( subject ).to receive( :puppet ) do |arg|
646
+ allow(subject).to receive(:puppet) do |arg|
657
647
  arg
658
648
  end
659
649
 
660
- version_result = double("version", :stdout => "6.0.0")
650
+ version_result = double('version', stdout: '6.0.0')
661
651
  expect(subject).to receive(:on).with(master, '--version').and_return(version_result)
662
652
  expect(subject).to receive(:version_is_less).and_return(false)
663
- expect(subject).to receive(:on).with(master, 'puppetserver ca sign --all', :acceptable_exit_codes => [0, 24]).once
653
+ expect(subject).to receive(:on).with(master, 'puppetserver ca sign --all', acceptable_exit_codes: [0, 24]).once
664
654
  expect(subject).to receive(:on).with(master, 'puppetserver ca list --all').once.and_return(result)
665
655
 
666
- subject.sign_certificate_for( agent )
656
+ subject.sign_certificate_for(agent)
667
657
  end
668
658
 
669
659
  it 'signs certs with `puppet cert` in Puppet 5' do
670
- allow( subject ).to receive( :sleep ).and_return( true )
660
+ allow(subject).to receive(:sleep).and_return(true)
671
661
 
672
662
  result.stdout = "+ \"#{agent}\""
673
663
 
674
- allow( subject ).to receive( :puppet ) do |arg|
664
+ allow(subject).to receive(:puppet) do |arg|
675
665
  arg
676
666
  end
677
667
 
678
- version_result = double("version", :stdout => "5.0.0")
668
+ version_result = double('version', stdout: '5.0.0')
679
669
  expect(subject).to receive(:on).with(master, '--version').and_return(version_result)
680
670
  expect(subject).to receive(:version_is_less).and_return(true)
681
- expect(subject).to receive(:on).with(master, 'cert --sign --all --allow-dns-alt-names', :acceptable_exit_codes => [0, 24]).once
682
- expect(subject).to receive(:on).with(master, 'cert --list --all').once.and_return( result )
671
+ expect(subject).to receive(:on).with(master, 'cert --sign --all --allow-dns-alt-names',
672
+ acceptable_exit_codes: [0, 24]).once
673
+ expect(subject).to receive(:on).with(master, 'cert --list --all').once.and_return(result)
683
674
 
684
- subject.sign_certificate_for( agent )
675
+ subject.sign_certificate_for(agent)
685
676
  end
686
677
 
687
678
  it 'retries 11 times before quitting' do
688
- allow( subject ).to receive( :sleep ).and_return( true )
679
+ allow(subject).to receive(:sleep).and_return(true)
689
680
 
690
681
  result.stdout = "Requested Certificates: \"#{agent}\""
691
- allow( subject ).to receive( :hosts ).and_return( hosts )
682
+ allow(subject).to receive(:hosts).and_return(hosts)
692
683
 
693
- allow( subject ).to receive( :puppet ) do |arg|
684
+ allow(subject).to receive(:puppet) do |arg|
694
685
  arg
695
686
  end
696
687
 
697
- version_result = double("version", :stdout => "6.0.0")
688
+ version_result = double('version', stdout: '6.0.0')
698
689
  expect(subject).to receive(:on).with(master, '--version').and_return(version_result)
699
- expect( subject ).to receive( :on ).with( master, 'puppetserver ca sign --all', :acceptable_exit_codes => [0, 24]).exactly( 11 ).times
700
- expect( subject ).to receive( :on ).with( master, 'puppetserver ca list --all').exactly( 11 ).times.and_return( result )
701
- expect( subject ).to receive( :fail_test ).once
690
+ expect(subject).to receive(:on).with(master, 'puppetserver ca sign --all',
691
+ acceptable_exit_codes: [0, 24]).exactly(11).times
692
+ expect(subject).to receive(:on).with(master,
693
+ 'puppetserver ca list --all').exactly(11).times.and_return(result)
694
+ expect(subject).to receive(:fail_test).once
702
695
 
703
- subject.sign_certificate_for( agent )
696
+ subject.sign_certificate_for(agent)
704
697
  end
705
698
 
706
699
  it 'accepts an array of hosts to validate' do
707
- allow( subject ).to receive( :sleep ).and_return( true )
700
+ allow(subject).to receive(:sleep).and_return(true)
708
701
 
709
702
  result.stdout = "+ \"#{agent}\" + \"#{custom}\""
710
- allow( subject ).to receive( :hosts ).and_return( hosts )
703
+ allow(subject).to receive(:hosts).and_return(hosts)
711
704
 
712
- allow( subject ).to receive( :puppet ) do |arg|
705
+ allow(subject).to receive(:puppet) do |arg|
713
706
  arg
714
707
  end
715
- expect( subject ).to receive( :on ).with( master, "agent -t", :acceptable_exit_codes => [0, 1, 2]).once
716
- version_result = double("version", :stdout => "6.0.0")
708
+ expect(subject).to receive(:on).with(master, 'agent -t', acceptable_exit_codes: [0, 1, 2]).once
709
+ version_result = double('version', stdout: '6.0.0')
717
710
  expect(subject).to receive(:on).with(master, '--version').and_return(version_result)
718
- expect( subject ).to receive( :on ).with( master, "puppetserver ca sign --certname master").once
719
- expect( subject ).to receive( :on ).with( master, "puppetserver ca sign --all", :acceptable_exit_codes => [0, 24]).once
720
- expect( subject ).to receive( :on ).with( master, "puppetserver ca list --all").once.and_return( result )
711
+ expect(subject).to receive(:on).with(master, 'puppetserver ca sign --certname master').once
712
+ expect(subject).to receive(:on).with(master, 'puppetserver ca sign --all',
713
+ acceptable_exit_codes: [0, 24]).once
714
+ expect(subject).to receive(:on).with(master, 'puppetserver ca list --all').once.and_return(result)
721
715
 
722
- subject.sign_certificate_for( [master, agent, custom] )
716
+ subject.sign_certificate_for([master, agent, custom])
723
717
  end
724
718
  end
725
719
 
726
- describe "#sign_certificate" do
720
+ describe '#sign_certificate' do
727
721
  it 'delegates to #sign_certificate_for with the default host' do
728
- allow( subject ).to receive( :hosts ).and_return( hosts )
729
- expect( subject ).to receive( :default ).and_return( master )
722
+ allow(subject).to receive(:hosts).and_return(hosts)
723
+ expect(subject).to receive(:default).and_return(master)
730
724
 
731
- expect( subject ).to receive( :sign_certificate_for ).with( master ).once
725
+ expect(subject).to receive(:sign_certificate_for).with(master).once
732
726
 
733
- subject.sign_certificate( )
727
+ subject.sign_certificate
734
728
  end
735
729
  end
736
730
 
@@ -740,136 +734,139 @@ describe ClassMixedWithDSLHelpers do
740
734
  let(:is_pe) { false }
741
735
  let(:use_service) { false }
742
736
  let(:platform) { 'redhat' }
743
- let(:host) {
737
+ let(:host) do
744
738
  FakeHost.create('fakevm', "#{platform}-version-arch",
745
- 'type' => is_pe ? 'pe': 'git',
746
- 'use-service' => use_service
747
- )
748
- }
739
+ 'type' => is_pe ? 'pe' : 'git',
740
+ 'use-service' => use_service)
741
+ end
749
742
 
750
743
  def stub_host_and_subject_to_allow_the_default_testdir_argument_to_be_created
751
744
  subject.instance_variable_set(:@path, test_case_path)
752
- allow( host ).to receive(:tmpdir).and_return(tmpdir_path)
753
- allow( host ).to receive(:file_exist?).and_return(true)
754
- allow( subject ).to receive( :options ).and_return( {} )
745
+ allow(host).to receive(:tmpdir).and_return(tmpdir_path)
746
+ allow(host).to receive(:file_exist?).and_return(true)
747
+ allow(subject).to receive(:options).and_return({})
755
748
  end
756
749
 
757
750
  before do
758
751
  stub_host_and_subject_to_allow_the_default_testdir_argument_to_be_created
759
- allow( subject ).to receive(:curl_with_retries)
752
+ allow(subject).to receive(:curl_with_retries)
760
753
  end
761
754
 
762
- it "raises an ArgumentError if you try to submit a String instead of a Hash of options" do
763
- expect { subject.with_puppet_running_on(host, '--foo --bar') }.to raise_error(ArgumentError, /conf_opts must be a Hash. You provided a String: '--foo --bar'/)
755
+ it 'raises an ArgumentError if you try to submit a String instead of a Hash of options' do
756
+ expect do
757
+ subject.with_puppet_running_on(host,
758
+ '--foo --bar')
759
+ end.to raise_error(ArgumentError, /conf_opts must be a Hash. You provided a String: '--foo --bar'/)
764
760
  end
765
761
 
766
762
  it 'raises the early_exception if backup_the_file fails' do
767
- allow( host ).to receive( :use_service_scripts? )
768
- allow( subject ).to receive( :restore_puppet_conf_from_backup )
769
- expect( subject ).to receive(:backup_the_file).and_raise(RuntimeError.new('puppet conf backup failed'))
770
- expect {
763
+ allow(host).to receive(:use_service_scripts?)
764
+ allow(subject).to receive(:restore_puppet_conf_from_backup)
765
+ expect(subject).to receive(:backup_the_file).and_raise(RuntimeError.new('puppet conf backup failed'))
766
+ expect do
771
767
  subject.with_puppet_running_on(host, {})
772
- }.to raise_error(RuntimeError, /puppet conf backup failed/)
768
+ end.to raise_error(RuntimeError, /puppet conf backup failed/)
773
769
  end
774
770
 
775
771
  it 'receives a Minitest::Assertion and fails the test correctly' do
776
- allow( subject ).to receive( :backup_the_file ).and_raise( Minitest::Assertion.new('assertion failed!') )
777
- allow( host ).to receive( :puppet ).and_return( {} )
778
- allow( subject ).to receive( :restore_puppet_conf_from_backup )
779
- allow( host ).to receive( :use_service_scripts? )
780
- expect( subject ).to receive( :fail_test )
772
+ allow(subject).to receive(:backup_the_file).and_raise(Minitest::Assertion.new('assertion failed!'))
773
+ allow(host).to receive(:puppet).and_return({})
774
+ allow(subject).to receive(:restore_puppet_conf_from_backup)
775
+ allow(host).to receive(:use_service_scripts?)
776
+ expect(subject).to receive(:fail_test)
781
777
  subject.with_puppet_running_on(host, {})
782
778
  end
783
779
 
784
780
  context 'with test flow exceptions' do
785
781
  it 'can pass_test' do
786
- expect( subject ).to receive(:backup_the_file).and_raise(Beaker::DSL::Outcomes::PassTest)
787
- expect {
782
+ expect(subject).to receive(:backup_the_file).and_raise(Beaker::DSL::Outcomes::PassTest)
783
+ expect do
788
784
  subject.with_puppet_running_on(host, {}).to receive(:pass_test)
789
- }.to raise_error(Beaker::DSL::Outcomes::PassTest)
785
+ end.to raise_error(Beaker::DSL::Outcomes::PassTest)
790
786
  end
791
787
  it 'can fail_test' do
792
- expect( subject ).to receive(:backup_the_file).and_raise(Beaker::DSL::Outcomes::FailTest)
793
- expect {
788
+ expect(subject).to receive(:backup_the_file).and_raise(Beaker::DSL::Outcomes::FailTest)
789
+ expect do
794
790
  subject.with_puppet_running_on(host, {}).to receive(:fail_test)
795
- }.to raise_error(Beaker::DSL::Outcomes::FailTest)
791
+ end.to raise_error(Beaker::DSL::Outcomes::FailTest)
796
792
  end
797
793
  it 'can skip_test' do
798
- expect( subject ).to receive(:backup_the_file).and_raise(Beaker::DSL::Outcomes::SkipTest)
799
- expect {
794
+ expect(subject).to receive(:backup_the_file).and_raise(Beaker::DSL::Outcomes::SkipTest)
795
+ expect do
800
796
  subject.with_puppet_running_on(host, {}).to receive(:skip_test)
801
- }.to raise_error(Beaker::DSL::Outcomes::SkipTest)
797
+ end.to raise_error(Beaker::DSL::Outcomes::SkipTest)
802
798
  end
803
799
  it 'can pending_test' do
804
- expect( subject ).to receive(:backup_the_file).and_raise(Beaker::DSL::Outcomes::PendingTest)
805
- expect {
800
+ expect(subject).to receive(:backup_the_file).and_raise(Beaker::DSL::Outcomes::PendingTest)
801
+ expect do
806
802
  subject.with_puppet_running_on(host, {}).to receive(:pending_test)
807
- }.to raise_error(Beaker::DSL::Outcomes::PendingTest)
803
+ end.to raise_error(Beaker::DSL::Outcomes::PendingTest)
808
804
  end
809
805
  end
810
806
 
811
807
  describe 'with puppet-server' do
812
- let(:default_confdir) { "/etc/puppet" }
813
- let(:default_vardir) { "/var/lib/puppet" }
808
+ let(:default_confdir) { '/etc/puppet' }
809
+ let(:default_vardir) { '/var/lib/puppet' }
814
810
 
815
- let(:custom_confdir) { "/tmp/etc/puppet" }
816
- let(:custom_vardir) { "/tmp/var/lib/puppet" }
811
+ let(:custom_confdir) { '/tmp/etc/puppet' }
812
+ let(:custom_vardir) { '/tmp/var/lib/puppet' }
817
813
 
818
- let(:command_line_args) {"--vardir=#{custom_vardir} --confdir=#{custom_confdir}"}
819
- let(:conf_opts) { {:__commandline_args__ => command_line_args,
820
- :is_puppetserver => true}}
814
+ let(:command_line_args) { "--vardir=#{custom_vardir} --confdir=#{custom_confdir}" }
815
+ let(:conf_opts) do
816
+ { __commandline_args__: command_line_args,
817
+ is_puppetserver: true, }
818
+ end
821
819
 
822
- let(:default_puppetserver_opts) {
823
- { "jruby-puppet" => {
824
- "master-conf-dir" => default_confdir,
825
- "master-var-dir" => default_vardir,
820
+ let(:default_puppetserver_opts) do
821
+ { 'jruby-puppet' => {
822
+ 'master-conf-dir' => default_confdir,
823
+ 'master-var-dir' => default_vardir,
826
824
  },
827
- "certificate-authority" => {
828
- "allow-subject-alt-names" => true,
829
- }
830
- }
831
- }
825
+ 'certificate-authority' => {
826
+ 'allow-subject-alt-names' => true,
827
+ }, }
828
+ end
832
829
 
833
- let(:custom_puppetserver_opts) {
834
- { "jruby-puppet" => {
835
- "master-conf-dir" => custom_confdir,
836
- "master-var-dir" => custom_vardir,
830
+ let(:custom_puppetserver_opts) do
831
+ { 'jruby-puppet' => {
832
+ 'master-conf-dir' => custom_confdir,
833
+ 'master-var-dir' => custom_vardir,
837
834
  },
838
- "certificate-authority" => {
839
- "allow-subject-alt-names" => true,
840
- }
841
- }
842
- }
835
+ 'certificate-authority' => {
836
+ 'allow-subject-alt-names' => true,
837
+ }, }
838
+ end
843
839
 
844
- let(:puppetserver_conf) { "/etc/puppetserver/conf.d/puppetserver.conf" }
840
+ let(:puppetserver_conf) { '/etc/puppetserver/conf.d/puppetserver.conf' }
845
841
  let(:logger) { double }
846
842
 
847
843
  def stub_post_setup
848
- allow( subject ).to receive( :restore_puppet_conf_from_backup)
849
- allow( subject ).to receive( :bounce_service)
850
- allow( subject ).to receive( :stop_puppet_from_source_on)
851
- allow( subject ).to receive( :dump_puppet_log)
852
- allow( subject ).to receive( :restore_puppet_conf_from_backup)
853
- allow( subject ).to receive( :puppet_master_started)
854
- allow( subject ).to receive( :start_puppet_from_source_on!)
855
- allow( subject ).to receive( :lay_down_new_puppet_conf)
856
- allow( subject ).to receive( :logger) .and_return( logger )
857
- allow( logger ).to receive( :error)
858
- allow( logger ).to receive( :debug)
844
+ allow(subject).to receive(:restore_puppet_conf_from_backup)
845
+ allow(subject).to receive(:bounce_service)
846
+ allow(subject).to receive(:stop_puppet_from_source_on)
847
+ allow(subject).to receive(:dump_puppet_log)
848
+ allow(subject).to receive(:restore_puppet_conf_from_backup)
849
+ allow(subject).to receive(:puppet_master_started)
850
+ allow(subject).to receive(:start_puppet_from_source_on!)
851
+ allow(subject).to receive(:lay_down_new_puppet_conf)
852
+ allow(subject).to receive(:logger).and_return(logger)
853
+ allow(logger).to receive(:error)
854
+ allow(logger).to receive(:debug)
859
855
  end
860
856
 
861
857
  before do
862
858
  stub_post_setup
863
- allow( subject ).to receive(:options).and_return({:is_puppetserver => true})
864
- allow( subject ).to receive(:modify_tk_config)
865
- allow( subject ).to receive(:puppet_config).with(host, 'confdir', anything).and_return(default_confdir)
866
- allow( subject ).to receive(:puppet_config).with(host, 'vardir', anything).and_return(default_vardir)
867
- allow( subject ).to receive(:puppet_config).with(host, 'config', anything).and_return("#{default_confdir}/puppet.conf")
859
+ allow(subject).to receive(:options).and_return({ is_puppetserver: true })
860
+ allow(subject).to receive(:modify_tk_config)
861
+ allow(subject).to receive(:puppet_config).with(host, 'confdir', anything).and_return(default_confdir)
862
+ allow(subject).to receive(:puppet_config).with(host, 'vardir', anything).and_return(default_vardir)
863
+ allow(subject).to receive(:puppet_config).with(host, 'config',
864
+ anything).and_return("#{default_confdir}/puppet.conf")
868
865
  end
869
866
 
870
867
  describe 'when the global option for :is_puppetserver is false' do
871
868
  it 'checks the option for the host object' do
872
- allow( subject ).to receive( :options) .and_return( {:is_puppetserver => false})
869
+ allow(subject).to receive(:options).and_return({ is_puppetserver: false })
873
870
  host[:is_puppetserver] = true
874
871
  expect(subject).to receive(:modify_tk_config)
875
872
  subject.with_puppet_running_on(host, conf_opts)
@@ -879,8 +876,8 @@ describe ClassMixedWithDSLHelpers do
879
876
  describe 'and command line args passed' do
880
877
  it 'modifies SUT trapperkeeper configuration w/ command line args' do
881
878
  host['puppetserver-confdir'] = '/etc/puppetserver/conf.d'
882
- expect( subject ).to receive( :modify_tk_config).with(host, puppetserver_conf,
883
- custom_puppetserver_opts)
879
+ expect(subject).to receive(:modify_tk_config).with(host, puppetserver_conf,
880
+ custom_puppetserver_opts)
884
881
  subject.with_puppet_running_on(host, conf_opts)
885
882
  end
886
883
  end
@@ -889,16 +886,16 @@ describe ClassMixedWithDSLHelpers do
889
886
  let(:command_line_args) { nil }
890
887
  it 'modifies SUT trapperkeeper configuration w/ puppet defaults' do
891
888
  host['puppetserver-confdir'] = '/etc/puppetserver/conf.d'
892
- expect( subject ).to receive( :modify_tk_config).with(host, puppetserver_conf,
893
- default_puppetserver_opts)
889
+ expect(subject).to receive(:modify_tk_config).with(host, puppetserver_conf,
890
+ default_puppetserver_opts)
894
891
  subject.with_puppet_running_on(host, conf_opts)
895
892
  end
896
893
  end
897
894
  end
898
895
 
899
- describe "with valid arguments" do
896
+ describe 'with valid arguments' do
900
897
  before do
901
- expect( Tempfile ).to receive(:open).with('beaker')
898
+ expect(Tempfile).to receive(:open).with('beaker')
902
899
  end
903
900
 
904
901
  context 'for pe hosts' do
@@ -913,7 +910,7 @@ describe ClassMixedWithDSLHelpers do
913
910
 
914
911
  it 'yields to a block in between bouncing service calls' do
915
912
  execution = 0
916
- allow( subject ).to receive(:curl_with_retries)
913
+ allow(subject).to receive(:curl_with_retries)
917
914
  expect do
918
915
  subject.with_puppet_running_on(host, {}) do
919
916
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(1).times
@@ -927,7 +924,7 @@ describe ClassMixedWithDSLHelpers do
927
924
 
928
925
  context ':restart_when_done flag set false' do
929
926
  it 'starts puppet once, stops it twice' do
930
- subject.with_puppet_running_on(host, { :restart_when_done => false })
927
+ subject.with_puppet_running_on(host, { restart_when_done: false })
931
928
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).once
932
929
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
933
930
  end
@@ -943,9 +940,9 @@ describe ClassMixedWithDSLHelpers do
943
940
 
944
941
  it 'yields to a block after bouncing service' do
945
942
  execution = 0
946
- allow( subject ).to receive(:curl_with_retries)
943
+ allow(subject).to receive(:curl_with_retries)
947
944
  expect do
948
- subject.with_puppet_running_on(host, { :restart_when_done => false }) do
945
+ subject.with_puppet_running_on(host, { restart_when_done: false }) do
949
946
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(1).times
950
947
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(1).times
951
948
  execution += 1
@@ -961,28 +958,28 @@ describe ClassMixedWithDSLHelpers do
961
958
  host.uses_passenger!
962
959
  end
963
960
  it 'bounces puppet twice' do
964
- allow( subject ).to receive(:curl_with_retries)
961
+ allow(subject).to receive(:curl_with_retries)
965
962
  subject.with_puppet_running_on(host, {})
966
963
  expect(host).to execute_commands_matching(/apachectl graceful/).exactly(2).times
967
964
  end
968
965
 
969
966
  it 'gracefully restarts using apache2ctl' do
970
- allow(host).to receive( :check_for_command ).and_return( true )
971
- allow( subject ).to receive(:curl_with_retries)
967
+ allow(host).to receive(:check_for_command).and_return(true)
968
+ allow(subject).to receive(:curl_with_retries)
972
969
  subject.with_puppet_running_on(host, {})
973
970
  expect(host).to execute_commands_matching(/apache2ctl graceful/).exactly(2).times
974
971
  end
975
972
 
976
973
  it 'gracefully restarts using apachectl' do
977
- allow(host).to receive( :check_for_command ).and_return( false )
978
- allow( subject ).to receive(:curl_with_retries)
974
+ allow(host).to receive(:check_for_command).and_return(false)
975
+ allow(subject).to receive(:curl_with_retries)
979
976
  subject.with_puppet_running_on(host, {})
980
977
  expect(host).to execute_commands_matching(/apachectl graceful/).exactly(2).times
981
978
  end
982
979
 
983
980
  it 'yields to a block after bouncing service' do
984
981
  execution = 0
985
- allow( subject ).to receive(:curl_with_retries)
982
+ allow(subject).to receive(:curl_with_retries)
986
983
  expect do
987
984
  subject.with_puppet_running_on(host, {}) do
988
985
  expect(host).to execute_commands_matching(/apachectl graceful/).once
@@ -994,16 +991,16 @@ describe ClassMixedWithDSLHelpers do
994
991
 
995
992
  context ':restart_when_done flag set false' do
996
993
  it 'bounces puppet once' do
997
- allow( subject ).to receive(:curl_with_retries)
998
- subject.with_puppet_running_on(host, { :restart_when_done => false })
994
+ allow(subject).to receive(:curl_with_retries)
995
+ subject.with_puppet_running_on(host, { restart_when_done: false })
999
996
  expect(host).to execute_commands_matching(/apachectl graceful/).once
1000
997
  end
1001
998
 
1002
999
  it 'yields to a block after bouncing service' do
1003
1000
  execution = 0
1004
- allow( subject ).to receive(:curl_with_retries)
1001
+ allow(subject).to receive(:curl_with_retries)
1005
1002
  expect do
1006
- subject.with_puppet_running_on(host, { :restart_when_done => false }) do
1003
+ subject.with_puppet_running_on(host, { restart_when_done: false }) do
1007
1004
  expect(host).to execute_commands_matching(/apachectl graceful/).once
1008
1005
  execution += 1
1009
1006
  end
@@ -1016,7 +1013,7 @@ describe ClassMixedWithDSLHelpers do
1016
1013
  let(:use_service) { true }
1017
1014
 
1018
1015
  it 'stops and starts master using service scripts twice' do
1019
- allow( subject ).to receive(:curl_with_retries)
1016
+ allow(subject).to receive(:curl_with_retries)
1020
1017
  subject.with_puppet_running_on(host, {})
1021
1018
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).exactly(2).times
1022
1019
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
@@ -1037,8 +1034,8 @@ describe ClassMixedWithDSLHelpers do
1037
1034
 
1038
1035
  context ':restart_when_done flag set false' do
1039
1036
  it 'stops (twice) and starts (once) master using service scripts' do
1040
- allow( subject ).to receive(:curl_with_retries)
1041
- subject.with_puppet_running_on(host, { :restart_when_done => false })
1037
+ allow(subject).to receive(:curl_with_retries)
1038
+ subject.with_puppet_running_on(host, { restart_when_done: false })
1042
1039
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).once
1043
1040
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).exactly(2).times
1044
1041
  end
@@ -1046,7 +1043,7 @@ describe ClassMixedWithDSLHelpers do
1046
1043
  it 'yields to a block after stopping and starting service' do
1047
1044
  execution = 0
1048
1045
  expect do
1049
- subject.with_puppet_running_on(host, { :restart_when_done => false }) do
1046
+ subject.with_puppet_running_on(host, { restart_when_done: false }) do
1050
1047
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=running/).once
1051
1048
  expect(host).to execute_commands_matching(/puppet resource service #{host['puppetservice']}.*ensure=stopped/).once
1052
1049
  execution += 1
@@ -1057,18 +1054,16 @@ describe ClassMixedWithDSLHelpers do
1057
1054
  end
1058
1055
 
1059
1056
  context 'running from source' do
1060
- let('use-service') { false }
1061
-
1062
1057
  it 'does not try to stop if not started' do
1063
- expect( subject ).to receive(:start_puppet_from_source_on!).and_return false
1064
- expect( subject ).to_not receive(:stop_puppet_from_source_on)
1058
+ expect(subject).to receive(:start_puppet_from_source_on!).and_return false
1059
+ expect(subject).to_not receive(:stop_puppet_from_source_on)
1065
1060
 
1066
1061
  subject.with_puppet_running_on(host, {})
1067
1062
  end
1068
1063
 
1069
1064
  context 'successfully' do
1070
1065
  before do
1071
- expect( host ).to receive(:port_open?).with(8140).and_return(true)
1066
+ expect(host).to receive(:port_open?).with(8140).and_return(true)
1072
1067
  end
1073
1068
 
1074
1069
  it 'starts puppet from source' do
@@ -1094,14 +1089,14 @@ describe ClassMixedWithDSLHelpers do
1094
1089
  end
1095
1090
 
1096
1091
  it 'passes on commandline args' do
1097
- subject.with_puppet_running_on(host, {:__commandline_args__ => '--with arg'})
1092
+ subject.with_puppet_running_on(host, { __commandline_args__: '--with arg' })
1098
1093
  expect(host).to execute_commands_matching(/^puppet master --with arg/).once
1099
1094
  end
1100
1095
 
1101
1096
  it 'is not affected by the :restart_when_done flag' do
1102
1097
  execution = 0
1103
1098
  expect do
1104
- subject.with_puppet_running_on(host, { :restart_when_done => true }) do
1099
+ subject.with_puppet_running_on(host, { restart_when_done: true }) do
1105
1100
  expect(host).to execute_commands_matching(/^puppet master/).once
1106
1101
  execution += 1
1107
1102
  end
@@ -1119,14 +1114,14 @@ describe ClassMixedWithDSLHelpers do
1119
1114
  end
1120
1115
 
1121
1116
  let(:original_location) { '/root/mock/puppet.conf' }
1122
- let(:backup_location) {
1117
+ let(:backup_location) do
1123
1118
  filename = File.basename(original_location)
1124
1119
  File.join(tmpdir_path, "#{filename}.bak")
1125
- }
1126
- let(:new_location) {
1120
+ end
1121
+ let(:new_location) do
1127
1122
  filename = File.basename(original_location)
1128
1123
  File.join(tmpdir_path, filename)
1129
- }
1124
+ end
1130
1125
 
1131
1126
  context 'when a puppetservice is used' do
1132
1127
  let(:use_service) { true }
@@ -1138,7 +1133,7 @@ describe ClassMixedWithDSLHelpers do
1138
1133
  end
1139
1134
 
1140
1135
  it 'restores puppet.conf before restarting' do
1141
- subject.with_puppet_running_on(host, { :restart_when_done => true })
1136
+ subject.with_puppet_running_on(host, { restart_when_done: true })
1142
1137
  expect(host).to execute_commands_matching_in_order(/cat '#{backup_location}' > '#{original_location}'/,
1143
1138
  /ensure=stopped/,
1144
1139
  /ensure=running/)
@@ -1147,7 +1142,7 @@ describe ClassMixedWithDSLHelpers do
1147
1142
 
1148
1143
  context 'when a puppetservice is not used' do
1149
1144
  before do
1150
- expect( host ).to receive(:port_open?).with(8140).and_return(true)
1145
+ expect(host).to receive(:port_open?).with(8140).and_return(true)
1151
1146
  end
1152
1147
 
1153
1148
  it 'backs up puppet.conf' do
@@ -1163,7 +1158,7 @@ describe ClassMixedWithDSLHelpers do
1163
1158
  end
1164
1159
 
1165
1160
  it "doesn't restore a non-existent file" do
1166
- allow( subject ).to receive(:backup_the_file)
1161
+ allow(subject).to receive(:backup_the_file)
1167
1162
  subject.with_puppet_running_on(host, {})
1168
1163
  expect(host).to execute_commands_matching(/rm -f '#{original_location}'/)
1169
1164
  end
@@ -1172,15 +1167,14 @@ describe ClassMixedWithDSLHelpers do
1172
1167
 
1173
1168
  let(:logger) { double.as_null_object }
1174
1169
  describe 'handling failures' do
1175
-
1176
1170
  before do
1177
- allow( subject ).to receive( :logger ).and_return( logger )
1178
- expect( subject ).to receive(:stop_puppet_from_source_on).and_raise(RuntimeError.new('Also failed in teardown.'))
1179
- expect( host ).to receive(:port_open?).with(8140).and_return(true)
1171
+ allow(subject).to receive(:logger).and_return(logger)
1172
+ expect(subject).to receive(:stop_puppet_from_source_on).and_raise(RuntimeError.new('Also failed in teardown.'))
1173
+ expect(host).to receive(:port_open?).with(8140).and_return(true)
1180
1174
  end
1181
1175
 
1182
1176
  it 'does not swallow an exception raised from within test block if ensure block also fails' do
1183
- expect( subject.logger ).to receive(:error).with(/Raised during attempt to teardown.*Also failed in teardown/)
1177
+ expect(subject.logger).to receive(:error).with(/Raised during attempt to teardown.*Also failed in teardown/)
1184
1178
 
1185
1179
  expect do
1186
1180
  subject.with_puppet_running_on(host, {}) { raise 'Failed while yielding.' }
@@ -1188,7 +1182,7 @@ describe ClassMixedWithDSLHelpers do
1188
1182
  end
1189
1183
 
1190
1184
  it 'dumps the puppet logs if there is an error in the teardown' do
1191
- expect( subject.logger ).to receive(:notify).with(/Dumping master log/)
1185
+ expect(subject.logger).to receive(:notify).with(/Dumping master log/)
1192
1186
 
1193
1187
  expect do
1194
1188
  subject.with_puppet_running_on(host, {})
@@ -1196,7 +1190,7 @@ describe ClassMixedWithDSLHelpers do
1196
1190
  end
1197
1191
 
1198
1192
  it 'does not mask the teardown error with an error from dumping the logs' do
1199
- expect( subject.logger ).to receive(:notify).with(/Dumping master log/).and_raise("Error from dumping logs")
1193
+ expect(subject.logger).to receive(:notify).with(/Dumping master log/).and_raise('Error from dumping logs')
1200
1194
 
1201
1195
  expect do
1202
1196
  subject.with_puppet_running_on(host, {})
@@ -1204,128 +1198,124 @@ describe ClassMixedWithDSLHelpers do
1204
1198
  end
1205
1199
 
1206
1200
  it 'does not swallow a teardown exception if no earlier exception was raised' do
1207
- expect( subject.logger).to_not receive(:error)
1201
+ expect(subject.logger).to_not receive(:error)
1208
1202
  expect do
1209
1203
  subject.with_puppet_running_on(host, {})
1210
1204
  end.to raise_error(RuntimeError, 'Also failed in teardown.')
1211
1205
  end
1212
-
1213
1206
  end
1214
-
1215
1207
  end
1216
1208
  end
1217
1209
 
1218
1210
  describe '#with_puppet_running' do
1219
1211
  it 'delegates to #with_puppet_running_on with the default host' do
1220
- allow( subject ).to receive( :hosts ).and_return( hosts )
1221
- expect( subject ).to receive( :default ).and_return( master )
1222
-
1223
- expect( subject ).to receive( :with_puppet_running_on ).with( master, {:opt => 'value'}, '/dir' ).once
1224
-
1225
- subject.with_puppet_running( {:opt => 'value'}, '/dir' )
1212
+ allow(subject).to receive(:hosts).and_return(hosts)
1213
+ expect(subject).to receive(:default).and_return(master)
1226
1214
 
1215
+ expect(subject).to receive(:with_puppet_running_on).with(master, { opt: 'value' }, '/dir').once
1227
1216
 
1217
+ subject.with_puppet_running({ opt: 'value' }, '/dir')
1228
1218
  end
1229
1219
  end
1230
1220
 
1231
1221
  describe '#bounce_service' do
1232
- let( :options ) { Beaker::Options::Presets.new.presets }
1233
- let( :result ) { double.as_null_object }
1222
+ let(:options) { Beaker::Options::Presets.new.presets }
1223
+ let(:result) { double.as_null_object }
1234
1224
  before :each do
1235
- allow( subject ).to receive( :options ) { options }
1225
+ allow(subject).to receive(:options) { options }
1236
1226
  end
1237
1227
 
1238
1228
  it 'requests a reload but not a restart if the reload is successful' do
1239
1229
  host = FakeHost.create
1240
- allow( result ).to receive( :exit_code ).and_return( 0 )
1241
- allow( host ).to receive( :any_exec_result ).and_return( result )
1242
- allow( host ).to receive( :graceful_restarts? ).and_return( false )
1230
+ allow(result).to receive(:exit_code).and_return(0)
1231
+ allow(host).to receive(:any_exec_result).and_return(result)
1232
+ allow(host).to receive(:graceful_restarts?).and_return(false)
1243
1233
 
1244
- expect( Beaker::Command ).to receive( :new ).with(
1245
- /service not_real_service reload/
1234
+ expect(Beaker::Command).to receive(:new).with(
1235
+ /service not_real_service reload/,
1246
1236
  ).once
1247
- expect( subject ).to receive( :puppet_resource ).never
1248
- subject.bounce_service( host, 'not_real_service')
1237
+ expect(subject).to receive(:puppet_resource).never
1238
+ subject.bounce_service(host, 'not_real_service')
1249
1239
  end
1250
1240
 
1251
1241
  it 'requests a restart if the reload fails' do
1252
1242
  host = FakeHost.create
1253
- allow( result ).to receive( :exit_code ).and_return( 1 )
1254
- allow( host ).to receive( :exec ).and_return( result )
1255
- expect( subject ).to receive( :curl_with_retries )
1256
- expect( subject ).to receive( :puppet_resource ).with(
1243
+ allow(result).to receive(:exit_code).and_return(1)
1244
+ allow(host).to receive(:exec).and_return(result)
1245
+ expect(subject).to receive(:curl_with_retries)
1246
+ expect(subject).to receive(:puppet_resource).with(
1257
1247
  anything, 'not_real_service', anything
1258
- ).exactly( 2 ).times
1259
- subject.bounce_service( host, 'not_real_service' )
1248
+ ).exactly(2).times
1249
+ subject.bounce_service(host, 'not_real_service')
1260
1250
  end
1261
1251
 
1262
1252
  it 'uses the default port argument if none given' do
1263
1253
  host = FakeHost.create
1264
- expect( host ).to receive( :graceful_restarts? ).and_return( false )
1265
- allow( result ).to receive( :exit_code ).and_return( 1 )
1266
- expect( subject ).to receive( :curl_with_retries ).with(
1254
+ expect(host).to receive(:graceful_restarts?).and_return(false)
1255
+ allow(result).to receive(:exit_code).and_return(1)
1256
+ expect(subject).to receive(:curl_with_retries).with(
1267
1257
  anything, anything, /8140/, anything, anything
1268
1258
  )
1269
- subject.bounce_service( host, 'not_real_service')
1259
+ subject.bounce_service(host, 'not_real_service')
1270
1260
  end
1271
1261
 
1272
1262
  it 'takes the port argument' do
1273
1263
  host = FakeHost.create
1274
- expect( host ).to receive( :graceful_restarts? ).and_return( false )
1275
- allow( result ).to receive( :exit_code ).and_return( 1 )
1276
- expect( subject ).to receive( :curl_with_retries ).with(
1264
+ expect(host).to receive(:graceful_restarts?).and_return(false)
1265
+ allow(result).to receive(:exit_code).and_return(1)
1266
+ expect(subject).to receive(:curl_with_retries).with(
1277
1267
  anything, anything, /8000/, anything, anything
1278
1268
  )
1279
- subject.bounce_service( host, 'not_real_service', nil, 8000)
1269
+ subject.bounce_service(host, 'not_real_service', nil, 8000)
1280
1270
  end
1281
1271
  end
1282
1272
 
1283
1273
  describe '#sleep_until_puppetdb_started' do
1284
- let( :options ) do # defaults from presets.rb
1274
+ let(:options) do # defaults from presets.rb
1285
1275
  {
1286
- :puppetdb_port_nonssl => 8080,
1287
- :puppetdb_port_ssl => 8081
1276
+ puppetdb_port_nonssl: 8080,
1277
+ puppetdb_port_ssl: 8081,
1288
1278
  }
1289
1279
  end
1290
1280
 
1291
1281
  before :each do
1292
- allow( subject ).to receive( :options ) { options }
1293
- allow( hosts[0] ).to receive( :node_name ).and_return( '' )
1294
- allow( subject ).to receive( :version_is_less ).and_return( true )
1282
+ allow(subject).to receive(:options) { options }
1283
+ allow(hosts[0]).to receive(:node_name).and_return('')
1284
+ allow(subject).to receive(:version_is_less).and_return(true)
1295
1285
  end
1296
1286
 
1297
1287
  it 'uses the default ports if none given' do
1298
1288
  host = hosts[0]
1299
- expect( subject ).to receive( :retry_on ).with( anything(), /8080/, anything() ).once.ordered
1300
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8081/, anything() ).once.ordered
1301
- subject.sleep_until_puppetdb_started( host )
1289
+ expect(subject).to receive(:retry_on).with(anything, /8080/, anything).once.ordered
1290
+ expect(subject).to receive(:curl_with_retries).with(anything, anything, /8081/, anything).once.ordered
1291
+ subject.sleep_until_puppetdb_started(host)
1302
1292
  end
1303
1293
 
1304
1294
  it 'allows setting the nonssl_port' do
1305
1295
  host = hosts[0]
1306
- expect( subject ).to receive( :retry_on ).with( anything(), /8084/, anything() ).once.ordered
1307
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8081/, anything() ).once.ordered
1296
+ expect(subject).to receive(:retry_on).with(anything, /8084/, anything).once.ordered
1297
+ expect(subject).to receive(:curl_with_retries).with(anything, anything, /8081/, anything).once.ordered
1308
1298
 
1309
- subject.sleep_until_puppetdb_started( host, 8084 )
1299
+ subject.sleep_until_puppetdb_started(host, 8084)
1310
1300
  end
1311
1301
 
1312
1302
  it 'allows setting the ssl_port' do
1313
1303
  host = hosts[0]
1314
- expect( subject ).to receive( :retry_on ).with( anything(), /8080/, anything() ).once.ordered
1315
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8085/, anything() ).once.ordered
1304
+ expect(subject).to receive(:retry_on).with(anything, /8080/, anything).once.ordered
1305
+ expect(subject).to receive(:curl_with_retries).with(anything, anything, /8085/, anything).once.ordered
1316
1306
 
1317
- subject.sleep_until_puppetdb_started( host, nil, 8085 )
1307
+ subject.sleep_until_puppetdb_started(host, nil, 8085)
1318
1308
  end
1319
1309
 
1320
1310
  context 'when pe_ver is less than 2016.1.0' do
1321
1311
  it 'uses the version endpoint' do
1322
1312
  host = hosts[0]
1323
1313
  host['pe_ver'] = '2015.3.3'
1324
- expect( subject ).to receive( :retry_on ).with( anything(), /pdb\/meta\/v1\/version/, anything() ).once.ordered
1325
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8081/, anything() ).once.ordered
1314
+ expect(subject).to receive(:retry_on).with(anything, %r{pdb/meta/v1/version}, anything).once.ordered
1315
+ expect(subject).to receive(:curl_with_retries).with(anything, anything, /8081/, anything).once.ordered
1326
1316
 
1327
- expect( subject ).to receive( :version_is_less ).with( host['pe_ver'], '2016.1.0' ).and_return( true )
1328
- subject.sleep_until_puppetdb_started( host )
1317
+ expect(subject).to receive(:version_is_less).with(host['pe_ver'], '2016.1.0').and_return(true)
1318
+ subject.sleep_until_puppetdb_started(host)
1329
1319
  end
1330
1320
  end
1331
1321
 
@@ -1333,60 +1323,59 @@ describe ClassMixedWithDSLHelpers do
1333
1323
  it 'uses the status endpoint' do
1334
1324
  host = hosts[0]
1335
1325
  host['pe_ver'] = '2016.1.0'
1336
- expect( subject ).to receive( :retry_on ).with( anything(), /status\/v1\/services\/puppetdb-status/, anything() ).once.ordered
1337
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8081/, anything() ).once.ordered
1326
+ expect(subject).to receive(:retry_on).with(anything, %r{status/v1/services/puppetdb-status},
1327
+ anything).once.ordered
1328
+ expect(subject).to receive(:curl_with_retries).with(anything, anything, /8081/, anything).once.ordered
1338
1329
 
1339
- expect( subject ).to receive( :version_is_less ).with( host['pe_ver'], '2016.1.0' ).and_return( false )
1340
- subject.sleep_until_puppetdb_started( host )
1330
+ expect(subject).to receive(:version_is_less).with(host['pe_ver'], '2016.1.0').and_return(false)
1331
+ subject.sleep_until_puppetdb_started(host)
1341
1332
  end
1342
1333
  end
1343
-
1344
1334
  end
1345
1335
 
1346
1336
  describe '#sleep_until_puppetserver_started' do
1347
- let( :options ) do
1348
- { :puppetserver_port => 8140 }
1337
+ let(:options) do
1338
+ { puppetserver_port: 8140 }
1349
1339
  end
1350
1340
 
1351
1341
  before :each do
1352
- allow( subject ).to receive( :options ) { options }
1353
- allow( hosts[0] ).to receive( :node_name )
1342
+ allow(subject).to receive(:options) { options }
1343
+ allow(hosts[0]).to receive(:node_name)
1354
1344
  end
1355
1345
 
1356
1346
  it 'uses the default port if none given' do
1357
1347
  host = hosts[0]
1358
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8140/, anything() ).once.ordered
1359
- subject.sleep_until_puppetserver_started( host )
1348
+ expect(subject).to receive(:curl_with_retries).with(anything, anything, /8140/, anything).once.ordered
1349
+ subject.sleep_until_puppetserver_started(host)
1360
1350
  end
1361
1351
 
1362
1352
  it 'allows setting the port' do
1363
1353
  host = hosts[0]
1364
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /8147/, anything() ).once.ordered
1365
- subject.sleep_until_puppetserver_started( host, 8147 )
1354
+ expect(subject).to receive(:curl_with_retries).with(anything, anything, /8147/, anything).once.ordered
1355
+ subject.sleep_until_puppetserver_started(host, 8147)
1366
1356
  end
1367
1357
  end
1368
1358
 
1369
1359
  describe '#sleep_until_nc_started' do
1370
- let( :options ) do # defaults from presets.rb
1371
- { :nodeclassifier_port => 4433 }
1360
+ let(:options) do # defaults from presets.rb
1361
+ { nodeclassifier_port: 4433 }
1372
1362
  end
1373
1363
 
1374
1364
  before :each do
1375
- allow( subject ).to receive( :options ) { options }
1376
- allow( hosts[0] ).to receive( :node_name )
1365
+ allow(subject).to receive(:options) { options }
1366
+ allow(hosts[0]).to receive(:node_name)
1377
1367
  end
1378
1368
 
1379
1369
  it 'uses the default port if none given' do
1380
1370
  host = hosts[0]
1381
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /4433/, anything() ).once.ordered
1382
- subject.sleep_until_nc_started( host )
1371
+ expect(subject).to receive(:curl_with_retries).with(anything, anything, /4433/, anything).once.ordered
1372
+ subject.sleep_until_nc_started(host)
1383
1373
  end
1384
1374
 
1385
1375
  it 'allows setting the port' do
1386
1376
  host = hosts[0]
1387
- expect( subject ).to receive( :curl_with_retries ).with( anything(), anything(), /4435/, anything() ).once.ordered
1388
- subject.sleep_until_nc_started( host, 4435 )
1377
+ expect(subject).to receive(:curl_with_retries).with(anything, anything, /4435/, anything).once.ordered
1378
+ subject.sleep_until_nc_started(host, 4435)
1389
1379
  end
1390
1380
  end
1391
-
1392
1381
  end