test-kitchen 1.4.2 → 1.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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +29 -33
  4. data/CHANGELOG.md +86 -2
  5. data/CONTRIBUTING.md +17 -0
  6. data/Gemfile.proxy_tests +5 -0
  7. data/MAINTAINERS.md +24 -0
  8. data/features/kitchen_driver_discover_command.feature +6 -0
  9. data/features/kitchen_init_command.feature +55 -7
  10. data/features/step_definitions/gem_steps.rb +12 -4
  11. data/features/step_definitions/git_steps.rb +1 -1
  12. data/features/step_definitions/output_steps.rb +1 -1
  13. data/features/support/env.rb +13 -9
  14. data/lib/kitchen/cli.rb +46 -5
  15. data/lib/kitchen/command/driver_discover.rb +8 -0
  16. data/lib/kitchen/command.rb +1 -0
  17. data/lib/kitchen/config.rb +4 -0
  18. data/lib/kitchen/configurable.rb +32 -0
  19. data/lib/kitchen/driver/ssh_base.rb +18 -4
  20. data/lib/kitchen/generator/driver_create.rb +2 -2
  21. data/lib/kitchen/generator/init.rb +4 -4
  22. data/lib/kitchen/instance.rb +7 -0
  23. data/lib/kitchen/lazy_hash.rb +20 -0
  24. data/lib/kitchen/logger.rb +4 -7
  25. data/lib/kitchen/provisioner/base.rb +16 -1
  26. data/lib/kitchen/provisioner/chef_base.rb +43 -98
  27. data/lib/kitchen/provisioner/chef_solo.rb +7 -4
  28. data/lib/kitchen/provisioner/chef_zero.rb +12 -5
  29. data/lib/kitchen/ssh.rb +1 -1
  30. data/lib/kitchen/transport/base.rb +7 -0
  31. data/lib/kitchen/transport/ssh.rb +13 -6
  32. data/lib/kitchen/transport/winrm.rb +168 -50
  33. data/lib/kitchen/verifier/base.rb +18 -1
  34. data/lib/kitchen/verifier/busser.rb +12 -5
  35. data/lib/kitchen/verifier/shell.rb +101 -0
  36. data/lib/kitchen/version.rb +1 -2
  37. data/spec/kitchen/collection_spec.rb +1 -1
  38. data/spec/kitchen/configurable_spec.rb +211 -2
  39. data/spec/kitchen/driver/ssh_base_spec.rb +131 -8
  40. data/spec/kitchen/lazy_hash_spec.rb +27 -0
  41. data/spec/kitchen/logger_spec.rb +10 -0
  42. data/spec/kitchen/provisioner/base_spec.rb +25 -0
  43. data/spec/kitchen/provisioner/chef_base_spec.rb +133 -252
  44. data/spec/kitchen/provisioner/chef_solo_spec.rb +30 -0
  45. data/spec/kitchen/provisioner/chef_zero_spec.rb +27 -2
  46. data/spec/kitchen/provisioner/shell_spec.rb +60 -12
  47. data/spec/kitchen/ssh_spec.rb +1 -1
  48. data/spec/kitchen/transport/ssh_spec.rb +2 -1
  49. data/spec/kitchen/transport/winrm_spec.rb +228 -48
  50. data/spec/kitchen/verifier/base_spec.rb +26 -0
  51. data/spec/kitchen/verifier/busser_spec.rb +69 -3
  52. data/spec/kitchen/verifier/shell_spec.rb +157 -0
  53. data/support/busser_install_command.sh +1 -2
  54. data/support/chef_base_install_command.ps1 +19 -12
  55. data/templates/driver/README.md.erb +1 -1
  56. data/test-kitchen.gemspec +12 -3
  57. metadata +106 -10
@@ -27,6 +27,7 @@ describe Kitchen::Provisioner::ChefBase do
27
27
  let(:logger) { Logger.new(logged_output) }
28
28
  let(:platform) { stub(:os_type => nil) }
29
29
  let(:suite) { stub(:name => "fries") }
30
+ let(:default_version) { "true" }
30
31
 
31
32
  let(:config) do
32
33
  { :test_base_path => "/basist", :kitchen_root => "/rooty" }
@@ -55,10 +56,6 @@ describe Kitchen::Provisioner::ChefBase do
55
56
 
56
57
  before { platform.stubs(:os_type).returns("unix") }
57
58
 
58
- it ":chef_omnibus_root has a default" do
59
- provisioner[:chef_omnibus_root].must_equal "/opt/chef"
60
- end
61
-
62
59
  it ":chef_omnibus_url has a default" do
63
60
  provisioner[:chef_omnibus_url].
64
61
  must_equal "https://www.chef.io/chef/install.sh"
@@ -73,109 +70,11 @@ describe Kitchen::Provisioner::ChefBase do
73
70
 
74
71
  before { platform.stubs(:os_type).returns("windows") }
75
72
 
76
- it ":chef_omnibus_root has a default" do
77
- provisioner[:chef_omnibus_root].
78
- must_equal "$env:systemdrive\\opscode\\chef"
79
- end
80
-
81
73
  it ":chef_omnibus_url has a default" do
82
74
  provisioner[:chef_omnibus_url].
83
75
  must_equal "https://www.chef.io/chef/install.sh"
84
76
  end
85
77
 
86
- describe ":chef_metadata_url" do
87
-
88
- let(:base_url) { "https://www.chef.io/chef/metadata" }
89
-
90
- it "uses :chef_omnibus_url as url base if it ends in install.sh" do
91
- config[:chef_omnibus_url] = "https://woot/install.sh"
92
-
93
- provisioner[:chef_metadata_url].must_equal(
94
- "https://woot/metadata?p=windows&m=x86_64&pv=2008r2&v=latest"
95
- )
96
- end
97
-
98
- it "ignores :chef_omnibus_url if it doesn't end in install.sh" do
99
- config[:chef_omnibus_url] = "https://woot/other"
100
-
101
- provisioner[:chef_metadata_url].
102
- must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=latest"
103
- end
104
-
105
- it "defaults to latest package with :require_chef_omnibus = true" do
106
- config[:require_chef_omnibus] = true
107
-
108
- provisioner[:chef_metadata_url].
109
- must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=latest"
110
- end
111
-
112
- it "defaults to latest package with :require_chef_omnibus = latest" do
113
- config[:require_chef_omnibus] = "latest"
114
-
115
- provisioner[:chef_metadata_url].
116
- must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=latest"
117
- end
118
-
119
- it "defaults to a specific package from :require_chef_omnibus" do
120
- config[:require_chef_omnibus] = "11.12.13"
121
-
122
- provisioner[:chef_metadata_url].
123
- must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=11.12.13"
124
- end
125
-
126
- it "defaults to a maj/min version package from :require_chef_omnibus" do
127
- config[:require_chef_omnibus] = 12.1
128
-
129
- provisioner[:chef_metadata_url].
130
- must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=12.1"
131
- end
132
-
133
- it "defaults to a major package version from :require_chef_omnibus" do
134
- config[:require_chef_omnibus] = "16"
135
-
136
- provisioner[:chef_metadata_url].
137
- must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=16"
138
- end
139
-
140
- it "defaults to a prerelease package from :require_chef_omnibus" do
141
- config[:require_chef_omnibus] = "11.6.0.RC.1"
142
-
143
- provisioner[:chef_metadata_url].
144
- must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&v=11.6.0.rc.1"
145
- end
146
-
147
- it "defaults to a nightly package from :require_chef_omnibus" do
148
- config[:require_chef_omnibus] = "12.5.0-current.0+20150721082808.git.14.c91b337-1"
149
-
150
- provisioner[:chef_metadata_url].
151
- must_equal "#{base_url}?p=windows&m=x86_64&pv=2008r2&" \
152
- "v=12.5.0-current.0%2B20150721082808.git.14.c91b337-1"
153
- end
154
-
155
- it "defaults to a chefdk package from :chef_omnibus_install_options" do
156
- config[:require_chef_omnibus] = true
157
- config[:chef_omnibus_install_options] = "-P chefdk"
158
-
159
- provisioner[:chef_metadata_url].
160
- must_equal "#{base_url}-chefdk?p=windows&m=x86_64&pv=2008r2&v=latest"
161
- end
162
-
163
- it "defaults to a specfic chefdk from :chef_omnibus_install_options" do
164
- config[:require_chef_omnibus] = "0.3.6"
165
- config[:chef_omnibus_install_options] = "-a other -P chefdk -B okay"
166
-
167
- provisioner[:chef_metadata_url].
168
- must_equal "#{base_url}-chefdk?p=windows&m=x86_64&pv=2008r2&v=0.3.6"
169
- end
170
-
171
- it "defaults to a maj/min chefdk from :chef_omnibus_install_options" do
172
- config[:require_chef_omnibus] = "0.3"
173
- config[:chef_omnibus_install_options] = "-P chefdk -B okay"
174
-
175
- provisioner[:chef_metadata_url].
176
- must_equal "#{base_url}-chefdk?p=windows&m=x86_64&pv=2008r2&v=0.3"
177
- end
178
- end
179
78
  end
180
79
 
181
80
  it ":require_chef_omnibus defaults to true" do
@@ -240,259 +139,241 @@ describe Kitchen::Provisioner::ChefBase do
240
139
 
241
140
  describe "#install_command" do
242
141
 
243
- let(:cmd) { provisioner.install_command }
142
+ before do
143
+ platform.stubs(:shell_type).returns("bourne")
144
+ Mixlib::Install.stubs(:new).returns(installer)
145
+ end
244
146
 
245
- describe "for bourne shells" do
147
+ let(:installer) { stub(:root => "/rooty", :install_command => "make_it_so") }
246
148
 
247
- before { platform.stubs(:shell_type).returns("bourne") }
149
+ let(:cmd) { provisioner.install_command }
248
150
 
249
- it "returns nil if :require_chef_omnibus is falsey" do
250
- config[:require_chef_omnibus] = false
151
+ let(:install_opts) {
152
+ { :omnibus_url => "https://www.chef.io/chef/install.sh",
153
+ :project => nil, :install_flags => nil, :http_proxy => nil,
154
+ :https_proxy => nil }
155
+ }
251
156
 
252
- cmd.must_equal nil
253
- end
157
+ it "returns nil if :require_chef_omnibus is falsey" do
158
+ config[:require_chef_omnibus] = false
254
159
 
255
- it "uses bourne shell (sh)" do
256
- cmd.must_match(/\Ash -c '$/)
160
+ installer.expects(:root).never
161
+ installer.expects(:install_command).never
162
+ cmd.must_equal nil
163
+ end
164
+
165
+ describe "common behaviour" do
166
+ before do
167
+ installer.expects(:root).at_least_once.returns("/opt/chef")
168
+ installer.expects(:install_command)
257
169
  end
258
170
 
259
- it "ends with a single quote" do
260
- cmd.must_match(/'\Z/)
171
+ it "passes sensible defaults" do
172
+ Mixlib::Install.expects(:new).
173
+ with(default_version, false, install_opts).returns(installer)
174
+ cmd
261
175
  end
262
176
 
263
177
  it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
264
178
  config[:http_proxy] = "http://proxy"
179
+ install_opts[:http_proxy] = "http://proxy"
265
180
 
266
- cmd.lines.to_a[1..2].must_equal([
267
- %{http_proxy="http://proxy"; export http_proxy\n},
268
- %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n}
269
- ])
181
+ Mixlib::Install.expects(:new).
182
+ with(default_version, false, install_opts).returns(installer)
183
+ cmd
270
184
  end
271
185
 
272
186
  it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
273
187
  config[:https_proxy] = "https://proxy"
188
+ install_opts[:https_proxy] = "https://proxy"
274
189
 
275
- cmd.lines.to_a[1..2].must_equal([
276
- %{https_proxy="https://proxy"; export https_proxy\n},
277
- %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n}
278
- ])
190
+ Mixlib::Install.expects(:new).
191
+ with(default_version, false, install_opts).returns(installer)
192
+ cmd
279
193
  end
280
194
 
281
195
  it "exports all http proxy variables when both are set" do
282
196
  config[:http_proxy] = "http://proxy"
283
197
  config[:https_proxy] = "https://proxy"
198
+ install_opts[:http_proxy] = "http://proxy"
199
+ install_opts[:https_proxy] = "https://proxy"
284
200
 
285
- cmd.lines.to_a[1..4].must_equal([
286
- %{http_proxy="http://proxy"; export http_proxy\n},
287
- %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
288
- %{https_proxy="https://proxy"; export https_proxy\n},
289
- %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n}
290
- ])
201
+ Mixlib::Install.expects(:new).
202
+ with(default_version, false, install_opts).returns(installer)
203
+ cmd
291
204
  end
292
205
 
293
206
  it "installs chef using :chef_omnibus_url, if necessary" do
294
207
  config[:chef_omnibus_url] = "FROM_HERE"
208
+ install_opts[:omnibus_url] = "FROM_HERE"
295
209
 
296
- cmd.must_match regexify(%{chef_omnibus_url="FROM_HERE"})
210
+ Mixlib::Install.expects(:new).
211
+ with(default_version, false, install_opts).returns(installer)
212
+ cmd
297
213
  end
298
214
 
299
215
  it "will install a specific version of chef, if necessary" do
300
216
  config[:require_chef_omnibus] = "1.2.3"
301
217
 
302
- cmd.must_match regexify(%{install_flags="-v 1.2.3"})
303
- cmd.must_match regexify(%{pretty_version="1.2.3"})
304
- cmd.must_match regexify(%{version="1.2.3"})
218
+ Mixlib::Install.expects(:new).
219
+ with("1.2.3", false, install_opts).returns(installer)
220
+ cmd
305
221
  end
306
222
 
307
223
  it "will install a major/minor version of chef, if necessary" do
308
224
  config[:require_chef_omnibus] = "11.10"
309
225
 
310
- cmd.must_match regexify(%{install_flags="-v 11.10"})
311
- cmd.must_match regexify(%{pretty_version="11.10"})
312
- cmd.must_match regexify(%{version="11.10"})
226
+ Mixlib::Install.expects(:new).
227
+ with("11.10", false, install_opts).returns(installer)
228
+ cmd
313
229
  end
314
230
 
315
231
  it "will install a major version of chef, if necessary" do
316
232
  config[:require_chef_omnibus] = "12"
317
233
 
318
- cmd.must_match regexify(%{install_flags="-v 12"})
319
- cmd.must_match regexify(%{pretty_version="12"})
320
- cmd.must_match regexify(%{version="12"})
234
+ Mixlib::Install.expects(:new).
235
+ with("12", false, install_opts).returns(installer)
236
+ cmd
321
237
  end
322
238
 
323
239
  it "will install a downcaased version string of chef, if necessary" do
324
240
  config[:require_chef_omnibus] = "10.1.0.RC.1"
325
241
 
326
- cmd.must_match regexify(%{install_flags="-v 10.1.0.rc.1"})
327
- cmd.must_match regexify(%{pretty_version="10.1.0.rc.1"})
328
- cmd.must_match regexify(%{version="10.1.0.rc.1"})
242
+ Mixlib::Install.expects(:new).
243
+ with("10.1.0.rc.1", false, install_opts).returns(installer)
244
+ cmd
329
245
  end
330
246
 
331
247
  it "will install a nightly, if necessary" do
332
- config[:require_chef_omnibus] = "12.5.0-current.0+20150721082808.git.14.c91b337-1"
248
+ config[:require_chef_omnibus] =
249
+ "12.5.0-current.0+20150721082808.git.14.c91b337-1"
333
250
 
334
- cmd.must_match(
335
- regexify(%{install_flags="-v 12.5.0-current.0%2B20150721082808.git.14.c91b337-1"}))
336
- cmd.must_match(
337
- regexify(%{pretty_version="12.5.0-current.0+20150721082808.git.14.c91b337-1"}))
338
- cmd.must_match(
339
- regexify(%{version="12.5.0-current.0+20150721082808.git.14.c91b337-1"}))
251
+ Mixlib::Install.expects(:new).with(
252
+ "12.5.0-current.0+20150721082808.git.14.c91b337-1",
253
+ false,
254
+ install_opts
255
+ ).returns(installer)
256
+ cmd
340
257
  end
341
258
 
342
- it "will install the latest of chef, if necessary" do
259
+ it "will install the latest chef, if necessary" do
343
260
  config[:require_chef_omnibus] = "latest"
344
261
 
345
- cmd.must_match regexify(%{install_flags=""})
346
- cmd.must_match regexify(%{pretty_version="always install latest version"})
347
- cmd.must_match regexify(%{version="latest"})
262
+ Mixlib::Install.expects(:new).
263
+ with("latest", false, install_opts).returns(installer)
264
+ cmd
348
265
  end
349
266
 
350
- it "will install a of chef, unless it exists" do
267
+ it "will install a version of chef, unless it exists" do
351
268
  config[:require_chef_omnibus] = true
352
269
 
353
- cmd.must_match regexify(%{install_flags=""})
354
- cmd.must_match regexify(%{pretty_version="install only if missing"})
355
- cmd.must_match regexify(%{version="true"})
270
+ Mixlib::Install.expects(:new).
271
+ with(default_version, false, install_opts).returns(installer)
272
+ cmd
356
273
  end
357
274
 
358
- it "will pass install options, when given" do
275
+ it "will pass a project, when given" do
359
276
  config[:chef_omnibus_install_options] = "-P chefdk"
277
+ install_opts[:install_flags] = "-P chefdk"
278
+ install_opts[:project] = "chefdk"
360
279
 
361
- cmd.must_match regexify(%{install_flags="-P chefdk"})
362
- cmd.must_match regexify(%{pretty_version="install only if missing"})
363
- cmd.must_match regexify(%{version="true"})
280
+ Mixlib::Install.expects(:new).
281
+ with(default_version, false, install_opts).returns(installer)
282
+ cmd
364
283
  end
365
284
 
366
285
  it "will pass install options and version info, when given" do
367
286
  config[:require_chef_omnibus] = "11"
368
287
  config[:chef_omnibus_install_options] = "-d /tmp/place"
288
+ install_opts[:install_flags] = "-d /tmp/place"
369
289
 
370
- cmd.must_match regexify(%{install_flags="-v 11 -d /tmp/place"})
371
- cmd.must_match regexify(%{pretty_version="11"})
372
- cmd.must_match regexify(%{version="11"})
290
+ Mixlib::Install.expects(:new).
291
+ with("11", false, install_opts).returns(installer)
292
+ cmd
373
293
  end
374
294
 
375
- it "prepends sudo for sh commands when :sudo is set" do
376
- config[:sudo] = true
295
+ it "will set the install root" do
296
+ config[:chef_omnibus_root] = "/tmp/test"
297
+ install_opts[:root] = "/tmp/test"
377
298
 
378
- cmd.must_match regexify(%{sudo_sh="sudo -E sh"})
299
+ Mixlib::Install.expects(:new).
300
+ with(default_version, false, install_opts).returns(installer)
301
+ cmd
379
302
  end
380
303
 
381
- it "does not sudo for sh commands when :sudo is falsey" do
382
- config[:sudo] = false
304
+ it "prefixs the whole command with the command_prefix if set" do
305
+ config[:command_prefix] = "my_prefix"
383
306
 
384
- cmd.must_match regexify(%{sudo_sh="sh"})
307
+ cmd.must_match(/\Amy_prefix /)
385
308
  end
386
- end
387
309
 
388
- describe "for powershell shells on windows os types" do
389
-
390
- before do
391
- platform.stubs(:shell_type).returns("powershell")
392
- platform.stubs(:os_type).returns("windows")
393
- end
394
-
395
- it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
396
- config[:http_proxy] = "http://proxy"
397
-
398
- cmd.lines.to_a[0..1].must_equal([
399
- %{$env:http_proxy = "http://proxy"\n},
400
- %{$env:HTTP_PROXY = "http://proxy"\n}
401
- ])
402
- end
403
-
404
- it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
405
- config[:https_proxy] = "https://proxy"
406
-
407
- cmd.lines.to_a[0..1].must_equal([
408
- %{$env:https_proxy = "https://proxy"\n},
409
- %{$env:HTTPS_PROXY = "https://proxy"\n}
410
- ])
411
- end
412
-
413
- it "exports all http proxy variables when both are set" do
414
- config[:http_proxy] = "http://proxy"
415
- config[:https_proxy] = "https://proxy"
416
-
417
- cmd.lines.to_a[0..3].must_equal([
418
- %{$env:http_proxy = "http://proxy"\n},
419
- %{$env:HTTP_PROXY = "http://proxy"\n},
420
- %{$env:https_proxy = "https://proxy"\n},
421
- %{$env:HTTPS_PROXY = "https://proxy"\n}
422
- ])
423
- end
424
-
425
- it "returns nil if :require_chef_omnibus is falsey" do
426
- config[:require_chef_omnibus] = false
310
+ it "does not prefix the command if command_prefix is not set" do
311
+ config[:command_prefix] = nil
427
312
 
428
- cmd.must_equal nil
313
+ cmd.wont_match(/\Amy_prefix /)
429
314
  end
315
+ end
430
316
 
431
- it "installs chef using :chef_metadata_url, if necessary" do
432
- config[:chef_metadata_url] = "FROM_HERE"
433
-
434
- cmd.must_match regexify(%{$chef_metadata_url = "FROM_HERE"})
317
+ describe "for bourne shells" do
318
+ before do
319
+ installer.expects(:root).at_least_once.returns("/opt/chef")
320
+ installer.expects(:install_command).returns("my_install_command")
435
321
  end
436
322
 
437
- it "sets an root path from :chef_omnibus_root" do
438
- config[:chef_omnibus_root] = "\\a\\b"
323
+ it "prepends sudo for sh commands when :sudo is set" do
324
+ config[:sudo] = true
325
+ config[:sudo_command] = "my_sudo_command"
439
326
 
440
- cmd.must_match regexify(%{$chef_omnibus_root = "\\a\\b"})
327
+ Mixlib::Install.expects(:new).
328
+ with(default_version, false, install_opts).returns(installer)
329
+ cmd.must_equal "my_sudo_command my_install_command"
441
330
  end
442
331
 
443
- it "sets a path for the msi pacakge based on version" do
444
- config[:require_chef_omnibus] = "1.2.3"
332
+ it "does not sudo for sh commands when :sudo is falsey" do
333
+ config[:sudo] = false
445
334
 
446
- cmd.must_match regexify(%{$msi = "$env:TEMP\\chef-1.2.3.msi"})
335
+ Mixlib::Install.expects(:new).
336
+ with(default_version, false, install_opts).returns(installer)
337
+ cmd.must_equal "my_install_command"
447
338
  end
339
+ end
448
340
 
449
- it "will install a specific version of chef, if necessary" do
450
- config[:require_chef_omnibus] = "1.2.3"
451
-
452
- cmd.must_match regexify(%{$pretty_version = "1.2.3"})
453
- cmd.must_match regexify(%{$version = "1.2.3"})
341
+ describe "for powershell shells on windows os types" do
342
+ before do
343
+ installer.expects(:root).at_least_once.returns("/opt/chef")
344
+ installer.expects(:install_command)
345
+ platform.stubs(:shell_type).returns("powershell")
346
+ platform.stubs(:os_type).returns("windows")
454
347
  end
455
348
 
456
- it "will install a major/minor version of chef, if necessary" do
457
- config[:require_chef_omnibus] = "11.10"
458
-
459
- cmd.must_match regexify(%{$pretty_version = "11.10"})
460
- cmd.must_match regexify(%{$version = "11.10"})
349
+ it "sets the powershell flag for Mixlib::Install" do
350
+ Mixlib::Install.expects(:new).
351
+ with("", true, install_opts).returns(installer)
352
+ cmd
461
353
  end
354
+ end
355
+ end
462
356
 
463
- it "will install a major version of chef, if necessary" do
464
- config[:require_chef_omnibus] = "12"
357
+ describe "#init_command" do
465
358
 
466
- cmd.must_match regexify(%{$pretty_version = "12"})
467
- cmd.must_match regexify(%{$version = "12"})
468
- end
359
+ let(:cmd) { provisioner.init_command }
469
360
 
470
- it "will install a downcaased version string of chef, if necessary" do
471
- config[:require_chef_omnibus] = "10.1.0.RC.1"
361
+ describe "common behavior" do
472
362
 
473
- cmd.must_match regexify(%{$pretty_version = "10.1.0.rc.1"})
474
- cmd.must_match regexify(%{$version = "10.1.0.rc.1"})
475
- end
363
+ before { platform.stubs(:shell_type).returns("fake") }
476
364
 
477
- it "will install the latest of chef, if necessary" do
478
- config[:require_chef_omnibus] = "latest"
365
+ it "prefixs the whole command with the command_prefix if set" do
366
+ config[:command_prefix] = "my_prefix"
479
367
 
480
- cmd.must_match regexify(%{$pretty_version = "always install latest version"})
481
- cmd.must_match regexify(%{$version = "latest"})
368
+ cmd.must_match(/\Amy_prefix /)
482
369
  end
483
370
 
484
- it "will install a of chef, unless it exists" do
485
- config[:require_chef_omnibus] = true
371
+ it "does not prefix the command if command_prefix is not set" do
372
+ config[:command_prefix] = nil
486
373
 
487
- cmd.must_match regexify(%{$pretty_version = "install only if missing"})
488
- cmd.must_match regexify(%{$version = "true"})
374
+ cmd.wont_match(/\Amy_prefix /)
489
375
  end
490
376
  end
491
- end
492
-
493
- describe "#init_command" do
494
-
495
- let(:cmd) { provisioner.init_command }
496
377
 
497
378
  describe "for bourne shells" do
498
379
 
@@ -296,6 +296,23 @@ describe Kitchen::Provisioner::ChefSolo do
296
296
 
297
297
  let(:cmd) { provisioner.run_command }
298
298
 
299
+ describe "common behavior" do
300
+
301
+ before { platform.stubs(:shell_type).returns("fake") }
302
+
303
+ it "prefixs the whole command with the command_prefix if set" do
304
+ config[:command_prefix] = "my_prefix"
305
+
306
+ cmd.must_match(/\Amy_prefix /)
307
+ end
308
+
309
+ it "does not prefix the command if command_prefix is not set" do
310
+ config[:command_prefix] = nil
311
+
312
+ cmd.wont_match(/\Amy_prefix /)
313
+ end
314
+ end
315
+
299
316
  describe "for bourne shells" do
300
317
 
301
318
  before { platform.stubs(:shell_type).returns("bourne") }
@@ -407,6 +424,19 @@ describe Kitchen::Provisioner::ChefSolo do
407
424
 
408
425
  cmd.must_match regexify(" --logfile /a/out.log", :partial_line)
409
426
  end
427
+
428
+ it "sets profile-ruby flag when config element is set" do
429
+ config[:profile_ruby] = true
430
+
431
+ cmd.must_match regexify(
432
+ " --profile-ruby", :partial_line)
433
+ end
434
+
435
+ it "does not set profile-ruby flag when config element is falsey" do
436
+ config[:profile_ruby] = false
437
+
438
+ cmd.wont_match regexify(" --profile-ruby", :partial_line)
439
+ end
410
440
  end
411
441
 
412
442
  describe "for powershell shells on windows os types" do
@@ -588,8 +588,8 @@ describe Kitchen::Provisioner::ChefZero do
588
588
  " --config #{custom_base}client.rb", :partial_line)
589
589
  end
590
590
 
591
- it "sets log level flag on chef-client to auto by default" do
592
- cmd.must_match regexify(" --log_level auto", :partial_line)
591
+ it "sets log level flag on chef-client to warn by default" do
592
+ cmd.must_match regexify(" --log_level warn", :partial_line)
593
593
  end
594
594
 
595
595
  it "set log level flag for custom level" do
@@ -634,6 +634,18 @@ describe Kitchen::Provisioner::ChefZero do
634
634
  it "does not set logfile flag by default" do
635
635
  cmd.wont_match regexify(" --logfile ", :partial_line)
636
636
  end
637
+
638
+ it "prefixs the whole command with the command_prefix if set" do
639
+ config[:command_prefix] = "my_prefix"
640
+
641
+ cmd.must_match(/\Amy_prefix /)
642
+ end
643
+
644
+ it "does not prefix the command if command_prefix is not set" do
645
+ config[:command_prefix] = nil
646
+
647
+ cmd.wont_match(/\Amy_prefix /)
648
+ end
637
649
  end
638
650
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
639
651
 
@@ -674,6 +686,19 @@ describe Kitchen::Provisioner::ChefZero do
674
686
 
675
687
  cmd.wont_match regexify(" --chef-zero-port ", :partial_line)
676
688
  end
689
+
690
+ it "sets profile-ruby flag when config element is set" do
691
+ config[:profile_ruby] = true
692
+
693
+ cmd.must_match regexify(
694
+ " --profile-ruby", :partial_line)
695
+ end
696
+
697
+ it "does not set profile-ruby flag when config element is falsey" do
698
+ config[:profile_ruby] = false
699
+
700
+ cmd.wont_match regexify(" --profile-ruby", :partial_line)
701
+ end
677
702
  end
678
703
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
679
704