test-kitchen 1.14.1 → 1.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/Berksfile +1 -1
  3. data/CHANGELOG.md +7 -0
  4. data/Gemfile +1 -1
  5. data/Guardfile +5 -5
  6. data/Rakefile +5 -5
  7. data/bin/kitchen +1 -1
  8. data/features/step_definitions/gem_steps.rb +6 -6
  9. data/features/support/env.rb +6 -7
  10. data/lib/kitchen.rb +5 -7
  11. data/lib/kitchen/base64_stream.rb +2 -8
  12. data/lib/kitchen/cli.rb +76 -80
  13. data/lib/kitchen/collection.rb +0 -2
  14. data/lib/kitchen/color.rb +7 -9
  15. data/lib/kitchen/command.rb +0 -4
  16. data/lib/kitchen/command/action.rb +0 -3
  17. data/lib/kitchen/command/console.rb +4 -7
  18. data/lib/kitchen/command/diagnose.rb +7 -14
  19. data/lib/kitchen/command/driver_discover.rb +1 -4
  20. data/lib/kitchen/command/exec.rb +0 -3
  21. data/lib/kitchen/command/list.rb +9 -12
  22. data/lib/kitchen/command/login.rb +0 -3
  23. data/lib/kitchen/command/package.rb +0 -3
  24. data/lib/kitchen/command/sink.rb +6 -9
  25. data/lib/kitchen/command/test.rb +1 -4
  26. data/lib/kitchen/config.rb +25 -27
  27. data/lib/kitchen/configurable.rb +26 -31
  28. data/lib/kitchen/data_munger.rb +34 -36
  29. data/lib/kitchen/diagnostic.rb +5 -7
  30. data/lib/kitchen/driver.rb +3 -5
  31. data/lib/kitchen/driver/base.rb +0 -3
  32. data/lib/kitchen/driver/dummy.rb +0 -3
  33. data/lib/kitchen/driver/proxy.rb +0 -3
  34. data/lib/kitchen/driver/ssh_base.rb +13 -16
  35. data/lib/kitchen/errors.rb +11 -16
  36. data/lib/kitchen/generator/driver_create.rb +18 -21
  37. data/lib/kitchen/generator/init.rb +21 -26
  38. data/lib/kitchen/instance.rb +19 -23
  39. data/lib/kitchen/lazy_hash.rb +1 -2
  40. data/lib/kitchen/loader/yaml.rb +22 -25
  41. data/lib/kitchen/logger.rb +9 -14
  42. data/lib/kitchen/logging.rb +0 -3
  43. data/lib/kitchen/login_command.rb +0 -2
  44. data/lib/kitchen/metadata_chopper.rb +0 -2
  45. data/lib/kitchen/platform.rb +1 -3
  46. data/lib/kitchen/provisioner.rb +3 -5
  47. data/lib/kitchen/provisioner/base.rb +2 -5
  48. data/lib/kitchen/provisioner/chef/berkshelf.rb +1 -5
  49. data/lib/kitchen/provisioner/chef/common_sandbox.rb +24 -29
  50. data/lib/kitchen/provisioner/chef/librarian.rb +2 -6
  51. data/lib/kitchen/provisioner/chef/policyfile.rb +4 -8
  52. data/lib/kitchen/provisioner/chef_apply.rb +14 -17
  53. data/lib/kitchen/provisioner/chef_base.rb +43 -46
  54. data/lib/kitchen/provisioner/chef_solo.rb +10 -13
  55. data/lib/kitchen/provisioner/chef_zero.rb +22 -29
  56. data/lib/kitchen/provisioner/dummy.rb +0 -3
  57. data/lib/kitchen/provisioner/shell.rb +6 -9
  58. data/lib/kitchen/rake_tasks.rb +4 -6
  59. data/lib/kitchen/shell_out.rb +3 -5
  60. data/lib/kitchen/ssh.rb +16 -22
  61. data/lib/kitchen/state_file.rb +3 -5
  62. data/lib/kitchen/suite.rb +0 -2
  63. data/lib/kitchen/thor_tasks.rb +2 -4
  64. data/lib/kitchen/transport.rb +3 -5
  65. data/lib/kitchen/transport/base.rb +1 -7
  66. data/lib/kitchen/transport/dummy.rb +0 -4
  67. data/lib/kitchen/transport/ssh.rb +41 -47
  68. data/lib/kitchen/transport/winrm.rb +41 -40
  69. data/lib/kitchen/util.rb +1 -3
  70. data/lib/kitchen/verifier.rb +3 -5
  71. data/lib/kitchen/verifier/base.rb +2 -5
  72. data/lib/kitchen/verifier/busser.rb +24 -24
  73. data/lib/kitchen/verifier/dummy.rb +0 -3
  74. data/lib/kitchen/verifier/shell.rb +1 -3
  75. data/lib/kitchen/version.rb +1 -1
  76. data/lib/vendor/hash_recursive_merge.rb +0 -2
  77. data/spec/kitchen/base64_stream_spec.rb +3 -6
  78. data/spec/kitchen/cli_spec.rb +0 -2
  79. data/spec/kitchen/collection_spec.rb +4 -8
  80. data/spec/kitchen/color_spec.rb +0 -3
  81. data/spec/kitchen/config_spec.rb +91 -106
  82. data/spec/kitchen/configurable_spec.rb +44 -76
  83. data/spec/kitchen/data_munger_spec.rb +1178 -1247
  84. data/spec/kitchen/diagnostic_spec.rb +37 -38
  85. data/spec/kitchen/driver/base_spec.rb +7 -14
  86. data/spec/kitchen/driver/dummy_spec.rb +1 -7
  87. data/spec/kitchen/driver/proxy_spec.rb +2 -7
  88. data/spec/kitchen/driver/ssh_base_spec.rb +128 -149
  89. data/spec/kitchen/driver_spec.rb +7 -13
  90. data/spec/kitchen/errors_spec.rb +50 -60
  91. data/spec/kitchen/instance_spec.rb +217 -294
  92. data/spec/kitchen/lazy_hash_spec.rb +14 -18
  93. data/spec/kitchen/loader/yaml_spec.rb +201 -227
  94. data/spec/kitchen/logger_spec.rb +7 -15
  95. data/spec/kitchen/logging_spec.rb +1 -4
  96. data/spec/kitchen/login_command_spec.rb +3 -4
  97. data/spec/kitchen/metadata_chopper_spec.rb +0 -3
  98. data/spec/kitchen/platform_spec.rb +31 -32
  99. data/spec/kitchen/provisioner/base_spec.rb +22 -41
  100. data/spec/kitchen/provisioner/chef/policyfile_spec.rb +15 -15
  101. data/spec/kitchen/provisioner/chef_apply_spec.rb +8 -13
  102. data/spec/kitchen/provisioner/chef_base_spec.rb +150 -182
  103. data/spec/kitchen/provisioner/chef_solo_spec.rb +58 -72
  104. data/spec/kitchen/provisioner/chef_zero_spec.rb +99 -125
  105. data/spec/kitchen/provisioner/dummy_spec.rb +8 -11
  106. data/spec/kitchen/provisioner/shell_spec.rb +86 -103
  107. data/spec/kitchen/provisioner_spec.rb +5 -11
  108. data/spec/kitchen/shell_out_spec.rb +15 -19
  109. data/spec/kitchen/ssh_spec.rb +16 -35
  110. data/spec/kitchen/state_file_spec.rb +6 -11
  111. data/spec/kitchen/suite_spec.rb +5 -6
  112. data/spec/kitchen/transport/base_spec.rb +6 -14
  113. data/spec/kitchen/transport/ssh_spec.rb +39 -64
  114. data/spec/kitchen/transport/winrm_spec.rb +99 -127
  115. data/spec/kitchen/transport_spec.rb +7 -13
  116. data/spec/kitchen/util_spec.rb +17 -26
  117. data/spec/kitchen/verifier/base_spec.rb +24 -40
  118. data/spec/kitchen/verifier/busser_spec.rb +38 -68
  119. data/spec/kitchen/verifier/dummy_spec.rb +8 -11
  120. data/spec/kitchen/verifier/shell_spec.rb +14 -17
  121. data/spec/kitchen/verifier_spec.rb +7 -13
  122. data/spec/kitchen_spec.rb +4 -6
  123. data/spec/spec_helper.rb +1 -1
  124. data/spec/support/powershell_max_size_spec.rb +1 -2
  125. data/support/chef-client-zero.rb +3 -4
  126. data/test-kitchen.gemspec +4 -6
  127. metadata +9 -9
@@ -19,7 +19,6 @@
19
19
  require "delegate"
20
20
 
21
21
  module Kitchen
22
-
23
22
  # A modifed Hash object that may contain callables as a value which must be
24
23
  # executed in the context of another object. This allows for delayed
25
24
  # evaluation of a hash value while still looking and largely feeling like a
@@ -101,7 +100,7 @@ module Kitchen
101
100
  #
102
101
  # @return [Hash] a new hash
103
102
  def to_hash
104
- hash = Hash.new
103
+ hash = {}
105
104
  __getobj__.keys.each { |key| hash[key] = self[key] }
106
105
  hash
107
106
  end
@@ -27,9 +27,7 @@ end
27
27
  require "safe_yaml/load"
28
28
 
29
29
  module Kitchen
30
-
31
30
  module Loader
32
-
33
31
  # YAML file loader for Test Kitchen configuration. This class is
34
32
  # responisble for parsing the main YAML file and the local YAML if it
35
33
  # exists. Local file configuration will win over the default configuration.
@@ -38,7 +36,6 @@ module Kitchen
38
36
  #
39
37
  # @author Fletcher Nichol <fnichol@nichol.ca>
40
38
  class YAML
41
-
42
39
  # Creates a new loader that can parse and load YAML files.
43
40
  #
44
41
  # @param options [Hash] configuration for a new loader
@@ -70,7 +67,7 @@ module Kitchen
70
67
  #
71
68
  # @return [Hash] merged configuration data
72
69
  def read
73
- if !File.exist?(config_file)
70
+ unless File.exist?(config_file)
74
71
  raise UserError, "Kitchen YAML file #{config_file} does not exist."
75
72
  end
76
73
 
@@ -81,7 +78,7 @@ module Kitchen
81
78
  #
82
79
  # @return [Hash] a diagnostic hash
83
80
  def diagnose
84
- result = Hash.new
81
+ result = {}
85
82
  result[:process_erb] = @process_erb
86
83
  result[:process_local] = @process_local
87
84
  result[:process_global] = @process_global
@@ -123,10 +120,10 @@ module Kitchen
123
120
  # @api private
124
121
  def combined_hash
125
122
  y = if @process_global
126
- normalize(global_yaml).rmerge(normalize(yaml))
127
- else
128
- normalize(yaml)
129
- end
123
+ normalize(global_yaml).rmerge(normalize(yaml))
124
+ else
125
+ normalize(yaml)
126
+ end
130
127
  @process_local ? y.rmerge(normalize(local_yaml)) : y
131
128
  end
132
129
 
@@ -239,7 +236,7 @@ module Kitchen
239
236
  failure_hash(e, file)
240
237
  end
241
238
 
242
- { :filename => file, :raw_data => hash }
239
+ { filename: file, raw_data: hash }
243
240
  end
244
241
 
245
242
  # Generates a Hash respresenting a failure, given an Exception object.
@@ -250,11 +247,11 @@ module Kitchen
250
247
  # @api private
251
248
  def failure_hash(e, file = nil)
252
249
  result = {
253
- :error => {
254
- :exception => e.inspect,
255
- :message => e.message,
256
- :backtrace => e.backtrace
257
- }
250
+ error: {
251
+ exception: e.inspect,
252
+ message: e.message,
253
+ backtrace: e.backtrace,
254
+ },
258
255
  }
259
256
  result[:error][:raw_file] = IO.read(file) unless file.nil?
260
257
  result
@@ -268,7 +265,7 @@ module Kitchen
268
265
  # @api private
269
266
  def normalize(obj)
270
267
  if obj.is_a?(Hash)
271
- obj.inject(Hash.new) { |h, (k, v)| normalize_hash(h, k, v); h }
268
+ obj.inject({}) { |h, (k, v)| normalize_hash(h, k, v); h }
272
269
  else
273
270
  obj
274
271
  end
@@ -308,13 +305,13 @@ module Kitchen
308
305
  case key
309
306
  when "driver", "provisioner", "busser"
310
307
  hash[key] = if value.nil?
311
- Hash.new
312
- elsif value.is_a?(String)
313
- default_key = key == "busser" ? "version" : "name"
314
- { default_key => value }
315
- else
316
- normalize(value)
317
- end
308
+ {}
309
+ elsif value.is_a?(String)
310
+ default_key = key == "busser" ? "version" : "name"
311
+ { default_key => value }
312
+ else
313
+ normalize(value)
314
+ end
318
315
  else
319
316
  hash[key] = normalize(value)
320
317
  end
@@ -329,9 +326,9 @@ module Kitchen
329
326
  # @raise [UserError] if the string document cannot be parsed
330
327
  # @api private
331
328
  def parse_yaml_string(string, file_name)
332
- return Hash.new if string.nil? || string.empty?
329
+ return {} if string.nil? || string.empty?
333
330
 
334
- result = SafeYAML.load(string) || Hash.new
331
+ result = SafeYAML.load(string) || {}
335
332
  unless result.is_a?(Hash)
336
333
  raise UserError, "Error parsing #{file_name} as YAML " \
337
334
  "(Result of parse was not a Hash, but was a #{result.class}).\n" \
@@ -20,7 +20,6 @@ require "fileutils"
20
20
  require "logger"
21
21
 
22
22
  module Kitchen
23
-
24
23
  # Logging implementation for Kitchen. By default the console/stdout output
25
24
  # will be displayed differently than the file log output. Therefor, this
26
25
  # class wraps multiple loggers that conform to the stdlib `Logger` class
@@ -28,7 +27,6 @@ module Kitchen
28
27
  #
29
28
  # @author Fletcher Nichol <fnichol@nichol.ca>
30
29
  class Logger
31
-
32
30
  include ::Logger::Severity
33
31
 
34
32
  # @return [IO] the log device
@@ -59,10 +57,10 @@ module Kitchen
59
57
  # (default: `$stdout.tty?`)
60
58
  def initialize(options = {})
61
59
  @log_overwrite = if options[:log_overwrite].nil?
62
- default_log_overwrite
63
- else
64
- options[:log_overwrite]
65
- end
60
+ default_log_overwrite
61
+ else
62
+ options[:log_overwrite]
63
+ end
66
64
 
67
65
  @logdev = logdev_logger(options[:logdev], log_overwrite) if options[:logdev]
68
66
 
@@ -88,7 +86,6 @@ module Kitchen
88
86
  private :populate_loggers
89
87
 
90
88
  class << self
91
-
92
89
  private
93
90
 
94
91
  # @api private
@@ -297,7 +294,7 @@ module Kitchen
297
294
  logger = StdoutLogger.new(stdout)
298
295
  if colorize
299
296
  logger.formatter = proc do |_severity, _datetime, _progname, msg|
300
- Color.colorize("#{msg}", color).concat("\n")
297
+ Color.colorize(msg.to_s, color).concat("\n")
301
298
  end
302
299
  else
303
300
  logger.formatter = proc do |_severity, _datetime, _progname, msg|
@@ -340,8 +337,7 @@ module Kitchen
340
337
  # Internal class which adds a #banner method call that displays the
341
338
  # message with a callout arrow.
342
339
  class LogdevLogger < ::Logger
343
-
344
- alias_method :super_info, :info
340
+ alias super_info info
345
341
 
346
342
  # Dump one or more messages to info.
347
343
  #
@@ -370,9 +366,9 @@ module Kitchen
370
366
  # @api private
371
367
  def format_line(line)
372
368
  case line
373
- when %r{^-----> } then banner(line.gsub(%r{^[ >-]{6} }, ""))
374
- when %r{^>>>>>> } then error(line.gsub(%r{^[ >-]{6} }, ""))
375
- when %r{^ } then info(line.gsub(%r{^[ >-]{6} }, ""))
369
+ when /^-----> / then banner(line.gsub(/^[ >-]{6} /, ""))
370
+ when /^>>>>>> / then error(line.gsub(/^[ >-]{6} /, ""))
371
+ when /^ / then info(line.gsub(/^[ >-]{6} /, ""))
376
372
  else info(line)
377
373
  end
378
374
  end
@@ -381,7 +377,6 @@ module Kitchen
381
377
  # Internal class which reformats logging methods for display as console
382
378
  # output.
383
379
  class StdoutLogger < LogdevLogger
384
-
385
380
  # Log a debug message
386
381
  #
387
382
  # @param msg [String] a message
@@ -17,14 +17,11 @@
17
17
  # limitations under the License.
18
18
 
19
19
  module Kitchen
20
-
21
20
  # Mixin module that delegates logging methods to a local `#logger`.
22
21
  #
23
22
  # @author Fletcher Nichol <fnichol@nichol.ca>
24
23
  module Logging
25
-
26
24
  class << self
27
-
28
25
  private
29
26
 
30
27
  # @api private
@@ -17,13 +17,11 @@
17
17
  # limitations under the License.
18
18
 
19
19
  module Kitchen
20
-
21
20
  # Value object to track a shell command that will be passed to Kernel.exec
22
21
  # for execution.
23
22
  #
24
23
  # @author Fletcher Nichol <fnichol@nichol.ca>
25
24
  class LoginCommand
26
-
27
25
  # @return [String] login command
28
26
  attr_reader :command
29
27
 
@@ -17,14 +17,12 @@
17
17
  # limitations under the License.
18
18
 
19
19
  module Kitchen
20
-
21
20
  # A rather insane and questionable class to quickly consume a metadata.rb
22
21
  # file and return the cookbook name and version attributes.
23
22
  #
24
23
  # @see https://twitter.com/fnichol/status/281650077901144064
25
24
  # @see https://gist.github.com/4343327
26
25
  class MetadataChopper < Hash
27
-
28
26
  # Return an Array containing the cookbook name and version attributes,
29
27
  # or nil values if they could not be parsed.
30
28
  #
@@ -17,14 +17,12 @@
17
17
  # limitations under the License.
18
18
 
19
19
  module Kitchen
20
-
21
20
  # A target operating system environment in which convergence integration
22
21
  # will take place. This may represent a specific operating system, version,
23
22
  # and machine architecture.
24
23
  #
25
24
  # @author Fletcher Nichol <fnichol@nichol.ca>
26
25
  class Platform
27
-
28
26
  # @return [String] logical name of this platform
29
27
  attr_reader :name
30
28
 
@@ -61,7 +59,7 @@ module Kitchen
61
59
  #
62
60
  # @return [Hash] a diagnostic hash
63
61
  def diagnose
64
- { :os_type => os_type, :shell_type => shell_type }
62
+ { os_type: os_type, shell_type: shell_type }
65
63
  end
66
64
  end
67
65
  end
@@ -19,14 +19,12 @@
19
19
  require "thor/util"
20
20
 
21
21
  module Kitchen
22
-
23
22
  # A provisioner is responsible for generating the commands necessary to
24
23
  # install set up and use a configuration management tool such as Chef and
25
24
  # Puppet.
26
25
  #
27
26
  # @author Fletcher Nichol <fnichol@nichol.ca>
28
27
  module Provisioner
29
-
30
28
  # Default provisioner to use
31
29
  DEFAULT_PLUGIN = "chef_solo".freeze
32
30
 
@@ -46,9 +44,9 @@ module Kitchen
46
44
  object
47
45
  rescue LoadError, NameError
48
46
  raise ClientError,
49
- "Could not load the '#{plugin}' provisioner from the load path." \
50
- " Please ensure that your provisioner is installed as a gem or" \
51
- " included in your Gemfile if using Bundler."
47
+ "Could not load the '#{plugin}' provisioner from the load path." \
48
+ " Please ensure that your provisioner is installed as a gem or" \
49
+ " included in your Gemfile if using Bundler."
52
50
  end
53
51
  end
54
52
  end
@@ -17,14 +17,11 @@
17
17
  # limitations under the License.
18
18
 
19
19
  module Kitchen
20
-
21
20
  module Provisioner
22
-
23
21
  # Base class for a provisioner.
24
22
  #
25
23
  # @author Fletcher Nichol <fnichol@nichol.ca>
26
24
  class Base
27
-
28
25
  include Configurable
29
26
  include Logging
30
27
 
@@ -37,7 +34,7 @@ module Kitchen
37
34
  default_config :wait_for_retry, 30
38
35
 
39
36
  default_config :root_path do |provisioner|
40
- provisioner.windows_os? ? "$env:TEMP\\kitchen" : "/tmp/kitchen"
37
+ provisioner.windows_os? ? '$env:TEMP\\kitchen' : "/tmp/kitchen"
41
38
  end
42
39
 
43
40
  default_config :sudo do |provisioner|
@@ -205,7 +202,7 @@ module Kitchen
205
202
  def shell_code_from_file(vars, file)
206
203
  src_file = File.join(
207
204
  File.dirname(__FILE__),
208
- %w[.. .. .. support],
205
+ %w{.. .. .. support},
209
206
  file + (powershell_shell? ? ".ps1" : ".sh")
210
207
  )
211
208
 
@@ -20,17 +20,13 @@ require "kitchen/errors"
20
20
  require "kitchen/logging"
21
21
 
22
22
  module Kitchen
23
-
24
23
  module Provisioner
25
-
26
24
  module Chef
27
-
28
25
  # Chef cookbook resolver that uses Berkshelf and a Berksfile to calculate
29
26
  # dependencies.
30
27
  #
31
28
  # @author Fletcher Nichol <fnichol@nichol.ca>
32
29
  class Berkshelf
33
-
34
30
  include Logging
35
31
 
36
32
  # Creates a new cookbook resolver.
@@ -109,7 +105,7 @@ module Kitchen
109
105
  " `gem install berkshelf` or add the following to your" \
110
106
  " Gemfile if you are using Bundler: `gem 'berkshelf'`.")
111
107
  raise UserError,
112
- "Could not load or activate Berkshelf (#{e.message})"
108
+ "Could not load or activate Berkshelf (#{e.message})"
113
109
  end
114
110
  end
115
111
  end
@@ -19,18 +19,14 @@
19
19
  require "json"
20
20
 
21
21
  module Kitchen
22
-
23
22
  module Provisioner
24
-
25
23
  module Chef
26
-
27
24
  # Internal object to manage common sandbox preparation for
28
25
  # Chef-related provisioners.
29
26
  #
30
27
  # @author Fletcher Nichol <fnichol@nichol.ca>
31
28
  # @api private
32
29
  class CommonSandbox
33
-
34
30
  include Logging
35
31
 
36
32
  # Constructs a new object, taking config, a sandbox path, and an
@@ -58,9 +54,9 @@ module Kitchen
58
54
  prepare(:clients)
59
55
  prepare(
60
56
  :secret,
61
- :type => :file,
62
- :dest_name => "encrypted_data_bag_secret",
63
- :key_name => :encrypted_data_bag_secret_key_path
57
+ type: :file,
58
+ dest_name: "encrypted_data_bag_secret",
59
+ key_name: :encrypted_data_bag_secret_key_path
64
60
  )
65
61
  end
66
62
 
@@ -84,8 +80,8 @@ module Kitchen
84
80
  # @return [Array<String>] an array of absolute paths to files
85
81
  # @api private
86
82
  def all_files_in_cookbooks
87
- Dir.glob(File.join(tmpbooks_dir, "**/*"), File::FNM_DOTMATCH).
88
- select { |fn| File.file?(fn) && ! %w[. ..].include?(fn) }
83
+ Dir.glob(File.join(tmpbooks_dir, "**/*"), File::FNM_DOTMATCH)
84
+ .select { |fn| File.file?(fn) && ! %w{. ..}.include?(fn) }
89
85
  end
90
86
 
91
87
  # @return [String] an absolute path to a Policyfile, relative to the
@@ -151,8 +147,8 @@ module Kitchen
151
147
  debug("Using metadata.rb from #{metadata_rb}")
152
148
 
153
149
  cb_name = MetadataChopper.extract(metadata_rb).first || raise(UserError,
154
- "The metadata.rb does not define the 'name' key." \
155
- " Please add: `name '<cookbook_name>'` to metadata.rb and retry")
150
+ "The metadata.rb does not define the 'name' key." \
151
+ " Please add: `name '<cookbook_name>'` to metadata.rb and retry")
156
152
 
157
153
  cb_path = File.join(tmpbooks_dir, cb_name)
158
154
 
@@ -168,8 +164,8 @@ module Kitchen
168
164
  def filter_only_cookbook_files
169
165
  info("Removing non-cookbook files before transfer")
170
166
  FileUtils.rm(all_files_in_cookbooks - only_cookbook_files)
171
- Dir.glob(File.join(tmpbooks_dir, "**/"), File::FNM_PATHNAME).
172
- reverse_each { |fn| FileUtils.rmdir(fn) if Dir.entries(fn).size == 2 }
167
+ Dir.glob(File.join(tmpbooks_dir, "**/"), File::FNM_PATHNAME)
168
+ .reverse_each { |fn| FileUtils.rmdir(fn) if Dir.entries(fn).size == 2 }
173
169
  end
174
170
 
175
171
  # @return [Logger] the instance's logger or Test Kitchen's common
@@ -208,8 +204,8 @@ module Kitchen
208
204
  def only_cookbook_files
209
205
  glob = File.join(tmpbooks_dir, "*", "{#{config[:cookbook_files_glob]}}")
210
206
 
211
- Dir.glob(glob, File::FNM_DOTMATCH).
212
- select { |fn| File.file?(fn) && ! %w[. ..].include?(fn) }
207
+ Dir.glob(glob, File::FNM_DOTMATCH)
208
+ .select { |fn| File.file?(fn) && ! %w{. ..}.include?(fn) }
213
209
  end
214
210
 
215
211
  # Prepares a generic Chef component source directory or file for
@@ -226,7 +222,7 @@ module Kitchen
226
222
  # basename in the sandbox path (default: `component.to_s`)
227
223
  # @api private
228
224
  def prepare(component, opts = {})
229
- opts = { :type => :directory }.merge(opts)
225
+ opts = { type: :directory }.merge(opts)
230
226
  key_name = opts.fetch(:key_name, "#{component}_path")
231
227
  src = config[key_name.to_sym]
232
228
  return if src.nil?
@@ -282,10 +278,10 @@ module Kitchen
282
278
  # @api private
283
279
  def prepare_json
284
280
  dna = if File.exist?(policyfile)
285
- update_dna_for_policyfile
286
- else
287
- config[:attributes].merge(:run_list => config[:run_list])
288
- end
281
+ update_dna_for_policyfile
282
+ else
283
+ config[:attributes].merge(run_list: config[:run_list])
284
+ end
289
285
 
290
286
  info("Preparing dna.json")
291
287
  debug("Creating dna.json from #{dna.inspect}")
@@ -302,14 +298,14 @@ module Kitchen
302
298
  warn("Ignored run_list: #{config[:run_list].inspect}")
303
299
  end
304
300
  policy = Chef::Policyfile.new(policyfile, sandbox_path,
305
- :logger => logger,
306
- :always_update => config[:always_update_cookbooks])
301
+ logger: logger,
302
+ always_update: config[:always_update_cookbooks])
307
303
  Kitchen.mutex.synchronize do
308
304
  policy.compile
309
305
  end
310
306
  policy_name = JSON.parse(IO.read(policy.lockfile))["name"]
311
307
  policy_group = "local"
312
- config[:attributes].merge(:policy_name => policy_name, :policy_group => policy_group)
308
+ config[:attributes].merge(policy_name: policy_name, policy_group: policy_group)
313
309
  end
314
310
 
315
311
  # Performs a Policyfile cookbook resolution inside a common mutex.
@@ -318,8 +314,8 @@ module Kitchen
318
314
  def resolve_with_policyfile
319
315
  Kitchen.mutex.synchronize do
320
316
  Chef::Policyfile.new(policyfile, sandbox_path,
321
- :logger => logger,
322
- :always_update => config[:always_update_cookbooks]).resolve
317
+ logger: logger,
318
+ always_update: config[:always_update_cookbooks]).resolve
323
319
  end
324
320
  end
325
321
 
@@ -329,8 +325,8 @@ module Kitchen
329
325
  def resolve_with_berkshelf
330
326
  Kitchen.mutex.synchronize do
331
327
  Chef::Berkshelf.new(berksfile, tmpbooks_dir,
332
- :logger => logger,
333
- :always_update => config[:always_update_cookbooks]).resolve
328
+ logger: logger,
329
+ always_update: config[:always_update_cookbooks]).resolve
334
330
  end
335
331
  end
336
332
 
@@ -339,7 +335,7 @@ module Kitchen
339
335
  # @api private
340
336
  def resolve_with_librarian
341
337
  Kitchen.mutex.synchronize do
342
- Chef::Librarian.new(cheffile, tmpbooks_dir, :logger => logger).resolve
338
+ Chef::Librarian.new(cheffile, tmpbooks_dir, logger: logger).resolve
343
339
  end
344
340
  end
345
341
 
@@ -363,7 +359,6 @@ module Kitchen
363
359
  def tmpsitebooks_dir
364
360
  File.join(sandbox_path, "cookbooks")
365
361
  end
366
-
367
362
  end
368
363
  end
369
364
  end