test-kitchen 1.14.1 → 1.14.2

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 (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
@@ -23,11 +23,11 @@ describe Kitchen::Provisioner::Chef::Policyfile do
23
23
  let(:policyfile) { "" }
24
24
  let(:path) { "" }
25
25
  let(:null_logger) do
26
- stub(:fatal => nil, :error => nil, :warn => nil, :info => nil,
27
- :debug => nil, :banner => nil)
26
+ stub(fatal: nil, error: nil, warn: nil, info: nil,
27
+ debug: nil, banner: nil)
28
28
  end
29
29
  let(:described_object) do
30
- Kitchen::Provisioner::Chef::Policyfile.new(policyfile, path, :logger => null_logger)
30
+ Kitchen::Provisioner::Chef::Policyfile.new(policyfile, path, logger: null_logger)
31
31
  end
32
32
  let(:os) { "" }
33
33
  before do
@@ -64,7 +64,7 @@ describe Kitchen::Provisioner::Chef::Policyfile do
64
64
  let(:policyfile) { "/home/jenkins/My Chef Cookbook/workspace/current/Policyfile.rb" }
65
65
  let(:path) { "/tmp/kitchen/cookbooks" }
66
66
  it do
67
- described_object.expects(:run_command).with("chef export /home/jenkins/My\\ Chef\\ Cookbook/workspace/current/Policyfile.rb /tmp/kitchen/cookbooks --force")
67
+ described_object.expects(:run_command).with('chef export /home/jenkins/My\\ Chef\\ Cookbook/workspace/current/Policyfile.rb /tmp/kitchen/cookbooks --force')
68
68
  subject
69
69
  end
70
70
  end
@@ -74,19 +74,19 @@ describe Kitchen::Provisioner::Chef::Policyfile do
74
74
  let(:os) { "mswin" }
75
75
 
76
76
  describe "with simple paths" do
77
- let(:policyfile) { "C:\\cookbook\\Policyfile.rb" }
78
- let(:path) { "C:\\Temp\\kitchen\\cookbooks" }
77
+ let(:policyfile) { 'C:\\cookbook\\Policyfile.rb' }
78
+ let(:path) { 'C:\\Temp\\kitchen\\cookbooks' }
79
79
  it do
80
- described_object.expects(:run_command).with("chef export C:\\cookbook\\Policyfile.rb C:\\Temp\\kitchen\\cookbooks --force")
80
+ described_object.expects(:run_command).with('chef export C:\\cookbook\\Policyfile.rb C:\\Temp\\kitchen\\cookbooks --force')
81
81
  subject
82
82
  end
83
83
  end
84
84
 
85
85
  describe "with Jenkins-y paths" do
86
- let(:policyfile) { "C:\\Program Files\\Jenkins\\My Chef Cookbook\\workspace\\current\\Policyfile.rb" }
87
- let(:path) { "C:\\Temp\\kitchen\\cookbooks" }
86
+ let(:policyfile) { 'C:\\Program Files\\Jenkins\\My Chef Cookbook\\workspace\\current\\Policyfile.rb' }
87
+ let(:path) { 'C:\\Temp\\kitchen\\cookbooks' }
88
88
  it do
89
- described_object.expects(:run_command).with("chef export \"C:\\\\Program\\ Files\\\\Jenkins\\\\My\\ Chef\\ Cookbook\\\\workspace\\\\current\\\\Policyfile.rb\" C:\\Temp\\kitchen\\cookbooks --force")
89
+ described_object.expects(:run_command).with('chef export "C:\\\\Program\\ Files\\\\Jenkins\\\\My\\ Chef\\ Cookbook\\\\workspace\\\\current\\\\Policyfile.rb" C:\\Temp\\kitchen\\cookbooks --force')
90
90
  subject
91
91
  end
92
92
  end
@@ -110,7 +110,7 @@ describe Kitchen::Provisioner::Chef::Policyfile do
110
110
  describe "with Jenkins-y paths" do
111
111
  let(:policyfile) { "/home/jenkins/My Chef Cookbook/workspace/current/Policyfile.rb" }
112
112
  it do
113
- described_object.expects(:run_command).with("chef install /home/jenkins/My\\ Chef\\ Cookbook/workspace/current/Policyfile.rb")
113
+ described_object.expects(:run_command).with('chef install /home/jenkins/My\\ Chef\\ Cookbook/workspace/current/Policyfile.rb')
114
114
  subject
115
115
  end
116
116
  end
@@ -120,17 +120,17 @@ describe Kitchen::Provisioner::Chef::Policyfile do
120
120
  let(:os) { "mswin" }
121
121
 
122
122
  describe "with simple paths" do
123
- let(:policyfile) { "C:\\cookbook\\Policyfile.rb" }
123
+ let(:policyfile) { 'C:\\cookbook\\Policyfile.rb' }
124
124
  it do
125
- described_object.expects(:run_command).with("chef install C:\\cookbook\\Policyfile.rb")
125
+ described_object.expects(:run_command).with('chef install C:\\cookbook\\Policyfile.rb')
126
126
  subject
127
127
  end
128
128
  end
129
129
 
130
130
  describe "with Jenkins-y paths" do
131
- let(:policyfile) { "C:\\Program Files\\Jenkins\\My Chef Cookbook\\workspace\\current\\Policyfile.rb" }
131
+ let(:policyfile) { 'C:\\Program Files\\Jenkins\\My Chef Cookbook\\workspace\\current\\Policyfile.rb' }
132
132
  it do
133
- described_object.expects(:run_command).with("chef install \"C:\\\\Program\\ Files\\\\Jenkins\\\\My\\ Chef\\ Cookbook\\\\workspace\\\\current\\\\Policyfile.rb\"")
133
+ described_object.expects(:run_command).with('chef install "C:\\\\Program\\ Files\\\\Jenkins\\\\My\\ Chef\\ Cookbook\\\\workspace\\\\current\\\\Policyfile.rb"')
134
134
  subject
135
135
  end
136
136
  end
@@ -22,22 +22,21 @@ require "kitchen"
22
22
  require "kitchen/provisioner/chef_apply"
23
23
 
24
24
  describe Kitchen::Provisioner::ChefApply do
25
-
26
25
  let(:logged_output) { StringIO.new }
27
26
  let(:logger) { Logger.new(logged_output) }
28
- let(:platform) { stub(:os_type => nil) }
29
- let(:suite) { stub(:name => "fries") }
27
+ let(:platform) { stub(os_type: nil) }
28
+ let(:suite) { stub(name: "fries") }
30
29
 
31
30
  let(:config) do
32
- { :test_base_path => "/b", :kitchen_root => "/r" }
31
+ { test_base_path: "/b", kitchen_root: "/r" }
33
32
  end
34
33
 
35
34
  let(:instance) do
36
35
  stub(
37
- :name => "coolbeans",
38
- :logger => logger,
39
- :suite => suite,
40
- :platform => platform
36
+ name: "coolbeans",
37
+ logger: logger,
38
+ suite: suite,
39
+ platform: platform
41
40
  )
42
41
  end
43
42
 
@@ -54,7 +53,6 @@ describe Kitchen::Provisioner::ChefApply do
54
53
  end
55
54
 
56
55
  describe "default config" do
57
-
58
56
  it "sets :chef_apply_path to a path using :chef_omnibus_root" do
59
57
  config[:chef_omnibus_root] = "/nice/place"
60
58
 
@@ -63,7 +61,6 @@ describe Kitchen::Provisioner::ChefApply do
63
61
  end
64
62
 
65
63
  describe "#create_sandbox" do
66
-
67
64
  before do
68
65
  @root = Dir.mktmpdir
69
66
  config[:kitchen_root] = @root
@@ -79,15 +76,13 @@ describe Kitchen::Provisioner::ChefApply do
79
76
  end
80
77
 
81
78
  describe "#run_command" do
82
-
83
79
  before do
84
- config[:run_list] = %w[appry_recipe1 appry_recipe2]
80
+ config[:run_list] = %w{appry_recipe1 appry_recipe2}
85
81
  end
86
82
 
87
83
  let(:cmd) { provisioner.run_command }
88
84
 
89
85
  describe "for bourne shells" do
90
-
91
86
  before { platform.stubs(:shell_type).returns("bourne") }
92
87
 
93
88
  it "uses bourne shell" do
@@ -22,45 +22,42 @@ require "kitchen"
22
22
  require "kitchen/provisioner/chef_base"
23
23
 
24
24
  describe Kitchen::Provisioner::ChefBase do
25
-
26
25
  let(:logged_output) { StringIO.new }
27
26
  let(:logger) { Logger.new(logged_output) }
28
- let(:platform) { stub(:os_type => nil) }
29
- let(:driver) { stub(:cache_directory => nil) }
30
- let(:suite) { stub(:name => "fries") }
27
+ let(:platform) { stub(os_type: nil) }
28
+ let(:driver) { stub(cache_directory: nil) }
29
+ let(:suite) { stub(name: "fries") }
31
30
  let(:default_version) { true }
32
31
 
33
32
  let(:config) do
34
- { :test_base_path => "/basist", :kitchen_root => "/rooty" }
33
+ { test_base_path: "/basist", kitchen_root: "/rooty" }
35
34
  end
36
35
 
37
36
  let(:instance) do
38
37
  stub(
39
- :name => "coolbeans",
40
- :logger => logger,
41
- :suite => suite,
42
- :platform => platform,
43
- :driver => driver
38
+ name: "coolbeans",
39
+ logger: logger,
40
+ suite: suite,
41
+ platform: platform,
42
+ driver: driver
44
43
  )
45
44
  end
46
45
 
47
46
  let(:provisioner) do
48
- Class.new(Kitchen::Provisioner::ChefBase) {
47
+ Class.new(Kitchen::Provisioner::ChefBase) do
49
48
  def calculate_path(path, _opts = {})
50
49
  "<calculated>/#{path}"
51
50
  end
52
- }.new(config).finalize_config!(instance)
51
+ end.new(config).finalize_config!(instance)
53
52
  end
54
53
 
55
54
  describe "configuration" do
56
-
57
55
  describe "for unix operating systems" do
58
-
59
56
  before { platform.stubs(:os_type).returns("unix") }
60
57
 
61
58
  it ":chef_omnibus_url has a default" do
62
- provisioner[:chef_omnibus_url].
63
- must_equal "https://omnitruck.chef.io/install.sh"
59
+ provisioner[:chef_omnibus_url]
60
+ .must_equal "https://omnitruck.chef.io/install.sh"
64
61
  end
65
62
 
66
63
  it ":chef_metadata_url defaults to nil" do
@@ -69,12 +66,11 @@ describe Kitchen::Provisioner::ChefBase do
69
66
  end
70
67
 
71
68
  describe "for windows operating systems" do
72
-
73
69
  before { platform.stubs(:os_type).returns("windows") }
74
70
 
75
71
  it ":chef_omnibus_url has a default" do
76
- provisioner[:chef_omnibus_url].
77
- must_equal "https://omnitruck.chef.io/install.sh"
72
+ provisioner[:chef_omnibus_url]
73
+ .must_equal "https://omnitruck.chef.io/install.sh"
78
74
  end
79
75
  end
80
76
 
@@ -103,58 +99,57 @@ describe Kitchen::Provisioner::ChefBase do
103
99
  end
104
100
 
105
101
  it ":data_path uses calculate_path and is expanded" do
106
- provisioner[:data_path].
107
- must_equal os_safe_root_path("/rooty/<calculated>/data")
102
+ provisioner[:data_path]
103
+ .must_equal os_safe_root_path("/rooty/<calculated>/data")
108
104
  end
109
105
 
110
106
  it ":data_bags_path uses calculate_path and is expanded" do
111
- provisioner[:data_bags_path].
112
- must_equal os_safe_root_path("/rooty/<calculated>/data_bags")
107
+ provisioner[:data_bags_path]
108
+ .must_equal os_safe_root_path("/rooty/<calculated>/data_bags")
113
109
  end
114
110
 
115
111
  it ":environments_path uses calculate_path and is expanded" do
116
- provisioner[:environments_path].
117
- must_equal os_safe_root_path("/rooty/<calculated>/environments")
112
+ provisioner[:environments_path]
113
+ .must_equal os_safe_root_path("/rooty/<calculated>/environments")
118
114
  end
119
115
 
120
116
  it ":nodes_path uses calculate_path and is expanded" do
121
- provisioner[:nodes_path].
122
- must_equal os_safe_root_path("/rooty/<calculated>/nodes")
117
+ provisioner[:nodes_path]
118
+ .must_equal os_safe_root_path("/rooty/<calculated>/nodes")
123
119
  end
124
120
 
125
121
  it ":roles_path uses calculate_path and is expanded" do
126
- provisioner[:roles_path].
127
- must_equal os_safe_root_path("/rooty/<calculated>/roles")
122
+ provisioner[:roles_path]
123
+ .must_equal os_safe_root_path("/rooty/<calculated>/roles")
128
124
  end
129
125
 
130
126
  it ":clients_path uses calculate_path and is expanded" do
131
- provisioner[:clients_path].
132
- must_equal os_safe_root_path("/rooty/<calculated>/clients")
127
+ provisioner[:clients_path]
128
+ .must_equal os_safe_root_path("/rooty/<calculated>/clients")
133
129
  end
134
130
 
135
131
  it "...secret_key_path uses calculate_path and is expanded" do
136
- provisioner[:encrypted_data_bag_secret_key_path].
137
- must_equal os_safe_root_path("/rooty/<calculated>/encrypted_data_bag_secret_key")
132
+ provisioner[:encrypted_data_bag_secret_key_path]
133
+ .must_equal os_safe_root_path("/rooty/<calculated>/encrypted_data_bag_secret_key")
138
134
  end
139
135
  end
140
136
 
141
137
  describe "#install_command" do
142
-
143
138
  before do
144
139
  platform.stubs(:shell_type).returns("bourne")
145
140
  Mixlib::Install::ScriptGenerator.stubs(:new).returns(installer)
146
141
  end
147
142
 
148
- let(:installer) { stub(:root => "/rooty", :install_command => "make_it_so") }
143
+ let(:installer) { stub(root: "/rooty", install_command: "make_it_so") }
149
144
 
150
145
  let(:cmd) { provisioner.install_command }
151
146
 
152
- let(:install_opts) {
153
- { :omnibus_url => "https://omnitruck.chef.io/install.sh",
154
- :project => nil, :install_flags => nil,
155
- :sudo_command => "sudo -E", :http_proxy => nil, :https_proxy => nil
147
+ let(:install_opts) do
148
+ { omnibus_url: "https://omnitruck.chef.io/install.sh",
149
+ project: nil, install_flags: nil,
150
+ sudo_command: "sudo -E", http_proxy: nil, https_proxy: nil
156
151
  }
157
- }
152
+ end
158
153
 
159
154
  it "returns nil if :require_chef_omnibus is falsey" do
160
155
  config[:require_chef_omnibus] = false
@@ -171,8 +166,8 @@ describe Kitchen::Provisioner::ChefBase do
171
166
  end
172
167
 
173
168
  it "passes sensible defaults" do
174
- Mixlib::Install::ScriptGenerator.expects(:new).
175
- with(default_version, false, install_opts).returns(installer)
169
+ Mixlib::Install::ScriptGenerator.expects(:new)
170
+ .with(default_version, false, install_opts).returns(installer)
176
171
  cmd
177
172
  end
178
173
 
@@ -180,8 +175,8 @@ describe Kitchen::Provisioner::ChefBase do
180
175
  config[:http_proxy] = "http://proxy"
181
176
  install_opts[:http_proxy] = "http://proxy"
182
177
 
183
- Mixlib::Install::ScriptGenerator.expects(:new).
184
- with(default_version, false, install_opts).returns(installer)
178
+ Mixlib::Install::ScriptGenerator.expects(:new)
179
+ .with(default_version, false, install_opts).returns(installer)
185
180
  cmd
186
181
  end
187
182
 
@@ -189,8 +184,8 @@ describe Kitchen::Provisioner::ChefBase do
189
184
  config[:https_proxy] = "https://proxy"
190
185
  install_opts[:https_proxy] = "https://proxy"
191
186
 
192
- Mixlib::Install::ScriptGenerator.expects(:new).
193
- with(default_version, false, install_opts).returns(installer)
187
+ Mixlib::Install::ScriptGenerator.expects(:new)
188
+ .with(default_version, false, install_opts).returns(installer)
194
189
  cmd
195
190
  end
196
191
 
@@ -200,8 +195,8 @@ describe Kitchen::Provisioner::ChefBase do
200
195
  install_opts[:http_proxy] = "http://proxy"
201
196
  install_opts[:https_proxy] = "https://proxy"
202
197
 
203
- Mixlib::Install::ScriptGenerator.expects(:new).
204
- with(default_version, false, install_opts).returns(installer)
198
+ Mixlib::Install::ScriptGenerator.expects(:new)
199
+ .with(default_version, false, install_opts).returns(installer)
205
200
  cmd
206
201
  end
207
202
 
@@ -209,32 +204,32 @@ describe Kitchen::Provisioner::ChefBase do
209
204
  config[:chef_omnibus_url] = "FROM_HERE"
210
205
  install_opts[:omnibus_url] = "FROM_HERE"
211
206
 
212
- Mixlib::Install::ScriptGenerator.expects(:new).
213
- with(default_version, false, install_opts).returns(installer)
207
+ Mixlib::Install::ScriptGenerator.expects(:new)
208
+ .with(default_version, false, install_opts).returns(installer)
214
209
  cmd
215
210
  end
216
211
 
217
212
  it "will install a specific version of chef, if necessary" do
218
213
  config[:require_chef_omnibus] = "1.2.3"
219
214
 
220
- Mixlib::Install::ScriptGenerator.expects(:new).
221
- with("1.2.3", false, install_opts).returns(installer)
215
+ Mixlib::Install::ScriptGenerator.expects(:new)
216
+ .with("1.2.3", false, install_opts).returns(installer)
222
217
  cmd
223
218
  end
224
219
 
225
220
  it "will install a major/minor version of chef, if necessary" do
226
221
  config[:require_chef_omnibus] = "11.10"
227
222
 
228
- Mixlib::Install::ScriptGenerator.expects(:new).
229
- with("11.10", false, install_opts).returns(installer)
223
+ Mixlib::Install::ScriptGenerator.expects(:new)
224
+ .with("11.10", false, install_opts).returns(installer)
230
225
  cmd
231
226
  end
232
227
 
233
228
  it "will install a major version of chef, if necessary" do
234
229
  config[:require_chef_omnibus] = "12"
235
230
 
236
- Mixlib::Install::ScriptGenerator.expects(:new).
237
- with("12", false, install_opts).returns(installer)
231
+ Mixlib::Install::ScriptGenerator.expects(:new)
232
+ .with("12", false, install_opts).returns(installer)
238
233
  cmd
239
234
  end
240
235
 
@@ -253,16 +248,16 @@ describe Kitchen::Provisioner::ChefBase do
253
248
  it "will install the latest chef, if necessary" do
254
249
  config[:require_chef_omnibus] = "latest"
255
250
 
256
- Mixlib::Install::ScriptGenerator.expects(:new).
257
- with("latest", false, install_opts).returns(installer)
251
+ Mixlib::Install::ScriptGenerator.expects(:new)
252
+ .with("latest", false, install_opts).returns(installer)
258
253
  cmd
259
254
  end
260
255
 
261
256
  it "will install a version of chef, unless it exists" do
262
257
  config[:require_chef_omnibus] = true
263
258
 
264
- Mixlib::Install::ScriptGenerator.expects(:new).
265
- with(default_version, false, install_opts).returns(installer)
259
+ Mixlib::Install::ScriptGenerator.expects(:new)
260
+ .with(default_version, false, install_opts).returns(installer)
266
261
  cmd
267
262
  end
268
263
 
@@ -271,8 +266,8 @@ describe Kitchen::Provisioner::ChefBase do
271
266
  install_opts[:install_flags] = "-P chefdk"
272
267
  install_opts[:project] = "chefdk"
273
268
 
274
- Mixlib::Install::ScriptGenerator.expects(:new).
275
- with(default_version, false, install_opts).returns(installer)
269
+ Mixlib::Install::ScriptGenerator.expects(:new)
270
+ .with(default_version, false, install_opts).returns(installer)
276
271
  cmd
277
272
  end
278
273
 
@@ -281,8 +276,8 @@ describe Kitchen::Provisioner::ChefBase do
281
276
  config[:chef_omnibus_install_options] = "-d /tmp/place"
282
277
  install_opts[:install_flags] = "-d /tmp/place"
283
278
 
284
- Mixlib::Install::ScriptGenerator.expects(:new).
285
- with("11", false, install_opts).returns(installer)
279
+ Mixlib::Install::ScriptGenerator.expects(:new)
280
+ .with("11", false, install_opts).returns(installer)
286
281
  cmd
287
282
  end
288
283
 
@@ -290,8 +285,8 @@ describe Kitchen::Provisioner::ChefBase do
290
285
  config[:chef_omnibus_root] = "/tmp/test"
291
286
  install_opts[:root] = "/tmp/test"
292
287
 
293
- Mixlib::Install::ScriptGenerator.expects(:new).
294
- with(default_version, false, install_opts).returns(installer)
288
+ Mixlib::Install::ScriptGenerator.expects(:new)
289
+ .with(default_version, false, install_opts).returns(installer)
295
290
  cmd
296
291
  end
297
292
 
@@ -299,8 +294,8 @@ describe Kitchen::Provisioner::ChefBase do
299
294
  config[:install_msi_url] = "http://blah/blah.msi"
300
295
  install_opts[:install_msi_url] = "http://blah/blah.msi"
301
296
 
302
- Mixlib::Install::ScriptGenerator.expects(:new).
303
- with(default_version, false, install_opts).returns(installer)
297
+ Mixlib::Install::ScriptGenerator.expects(:new)
298
+ .with(default_version, false, install_opts).returns(installer)
304
299
  cmd
305
300
  end
306
301
 
@@ -322,8 +317,8 @@ describe Kitchen::Provisioner::ChefBase do
322
317
  it "will use driver.cache_directory to provide a cache directory" do
323
318
  install_opts[:install_flags] = "-d /tmp/custom/place"
324
319
 
325
- Mixlib::Install::ScriptGenerator.expects(:new).
326
- with(default_version, false, install_opts).returns(installer)
320
+ Mixlib::Install::ScriptGenerator.expects(:new)
321
+ .with(default_version, false, install_opts).returns(installer)
327
322
  cmd
328
323
  end
329
324
 
@@ -332,8 +327,8 @@ describe Kitchen::Provisioner::ChefBase do
332
327
  install_opts[:install_flags] = "-P cool -v 123 -d /tmp/custom/place"
333
328
  install_opts[:project] = "cool"
334
329
 
335
- Mixlib::Install::ScriptGenerator.expects(:new).
336
- with(default_version, false, install_opts).returns(installer)
330
+ Mixlib::Install::ScriptGenerator.expects(:new)
331
+ .with(default_version, false, install_opts).returns(installer)
337
332
  cmd
338
333
  end
339
334
 
@@ -342,8 +337,8 @@ describe Kitchen::Provisioner::ChefBase do
342
337
  install_opts[:install_flags] = "-P cool -d /path -v 123"
343
338
  install_opts[:project] = "cool"
344
339
 
345
- Mixlib::Install::ScriptGenerator.expects(:new).
346
- with(default_version, false, install_opts).returns(installer)
340
+ Mixlib::Install::ScriptGenerator.expects(:new)
341
+ .with(default_version, false, install_opts).returns(installer)
347
342
  cmd
348
343
  end
349
344
  end
@@ -436,8 +431,8 @@ describe Kitchen::Provisioner::ChefBase do
436
431
  install_opts_clone = install_opts.clone
437
432
  install_opts_clone[:sudo_command] = config[:sudo_command]
438
433
 
439
- Mixlib::Install::ScriptGenerator.expects(:new).
440
- with(default_version, false, install_opts_clone).returns(installer)
434
+ Mixlib::Install::ScriptGenerator.expects(:new)
435
+ .with(default_version, false, install_opts_clone).returns(installer)
441
436
  cmd.must_equal "my_sudo_command my_install_command"
442
437
  end
443
438
 
@@ -455,8 +450,8 @@ describe Kitchen::Provisioner::ChefBase do
455
450
 
456
451
  install_opts_clone = install_opts.clone
457
452
  install_opts_clone[:sudo_command] = ""
458
- Mixlib::Install::ScriptGenerator.expects(:new).
459
- with(default_version, false, install_opts_clone).returns(installer)
453
+ Mixlib::Install::ScriptGenerator.expects(:new)
454
+ .with(default_version, false, install_opts_clone).returns(installer)
460
455
  cmd.must_equal "my_install_command"
461
456
  end
462
457
  end
@@ -472,8 +467,8 @@ describe Kitchen::Provisioner::ChefBase do
472
467
  it "sets the powershell flag for Mixlib::Install" do
473
468
  install_opts_clone = install_opts.clone
474
469
  install_opts_clone[:sudo_command] = ""
475
- Mixlib::Install::ScriptGenerator.expects(:new).
476
- with(default_version, true, install_opts_clone).returns(installer)
470
+ Mixlib::Install::ScriptGenerator.expects(:new)
471
+ .with(default_version, true, install_opts_clone).returns(installer)
477
472
  cmd
478
473
  end
479
474
 
@@ -487,16 +482,16 @@ describe Kitchen::Provisioner::ChefBase do
487
482
  end
488
483
 
489
484
  describe "when driver implements the cache_directory" do
490
- before { driver.stubs(:cache_directory).returns("$env:TEMP\\dummy\\place") }
485
+ before { driver.stubs(:cache_directory).returns('$env:TEMP\\dummy\\place') }
491
486
 
492
487
  it "will have the same behavior on windows" do
493
488
  config[:chef_omnibus_install_options] = "-version 123"
494
489
  install_opts_clone = install_opts.clone
495
490
  install_opts_clone[:sudo_command] = ""
496
491
  install_opts_clone[:install_flags] = "-version 123"
497
- install_opts_clone[:install_flags] << " -download_directory $env:TEMP\\dummy\\place"
498
- Mixlib::Install::ScriptGenerator.expects(:new).
499
- with(default_version, true, install_opts_clone).returns(installer)
492
+ install_opts_clone[:install_flags] << ' -download_directory $env:TEMP\\dummy\\place'
493
+ Mixlib::Install::ScriptGenerator.expects(:new)
494
+ .with(default_version, true, install_opts_clone).returns(installer)
500
495
  cmd
501
496
  end
502
497
  end
@@ -504,11 +499,9 @@ describe Kitchen::Provisioner::ChefBase do
504
499
  end
505
500
 
506
501
  describe "#init_command" do
507
-
508
502
  let(:cmd) { provisioner.init_command }
509
503
 
510
504
  describe "common behavior" do
511
-
512
505
  before { platform.stubs(:shell_type).returns("fake") }
513
506
 
514
507
  it "prefixs the whole command with the command_prefix if set" do
@@ -525,7 +518,6 @@ describe Kitchen::Provisioner::ChefBase do
525
518
  end
526
519
 
527
520
  describe "for bourne shells" do
528
-
529
521
  before { platform.stubs(:shell_type).returns("bourne") }
530
522
 
531
523
  it "uses bourne shell" do
@@ -541,18 +533,18 @@ describe Kitchen::Provisioner::ChefBase do
541
533
  config[:http_proxy] = "http://proxy"
542
534
 
543
535
  cmd.lines.to_a[1..2].must_equal([
544
- %{http_proxy="http://proxy"; export http_proxy\n},
545
- %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n}
546
- ])
536
+ %{http_proxy="http://proxy"; export http_proxy\n},
537
+ %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
538
+ ])
547
539
  end
548
540
 
549
541
  it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
550
542
  config[:https_proxy] = "https://proxy"
551
543
 
552
544
  cmd.lines.to_a[1..2].must_equal([
553
- %{https_proxy="https://proxy"; export https_proxy\n},
554
- %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n}
555
- ])
545
+ %{https_proxy="https://proxy"; export https_proxy\n},
546
+ %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
547
+ ])
556
548
  end
557
549
 
558
550
  it "exports all http proxy variables when both are set" do
@@ -560,11 +552,11 @@ describe Kitchen::Provisioner::ChefBase do
560
552
  config[:https_proxy] = "https://proxy"
561
553
 
562
554
  cmd.lines.to_a[1..4].must_equal([
563
- %{http_proxy="http://proxy"; export http_proxy\n},
564
- %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
565
- %{https_proxy="https://proxy"; export https_proxy\n},
566
- %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n}
567
- ])
555
+ %{http_proxy="http://proxy"; export http_proxy\n},
556
+ %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
557
+ %{https_proxy="https://proxy"; export https_proxy\n},
558
+ %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
559
+ ])
568
560
  end
569
561
 
570
562
  it "prepends sudo for rm when :sudo is set" do
@@ -581,10 +573,10 @@ describe Kitchen::Provisioner::ChefBase do
581
573
 
582
574
  it "sets chef component dirs for deletion" do
583
575
  config[:root_path] = "/route"
584
- dirs = %W[
576
+ dirs = %w{
585
577
  /route/clients /route/cookbooks /route/data /route/data_bags
586
578
  /route/encrypted_data_bag_secret /route/environments /route/roles
587
- ].join(" ")
579
+ }.join(" ")
588
580
 
589
581
  cmd.must_match regexify(%{dirs="#{dirs}"})
590
582
  end
@@ -597,7 +589,6 @@ describe Kitchen::Provisioner::ChefBase do
597
589
  end
598
590
 
599
591
  describe "for powershell shells on windows os types" do
600
-
601
592
  before do
602
593
  platform.stubs(:shell_type).returns("powershell")
603
594
  platform.stubs(:os_type).returns("windows")
@@ -607,18 +598,18 @@ describe Kitchen::Provisioner::ChefBase do
607
598
  config[:http_proxy] = "http://proxy"
608
599
 
609
600
  cmd.lines.to_a[0..1].must_equal([
610
- %{$env:http_proxy = "http://proxy"\n},
611
- %{$env:HTTP_PROXY = "http://proxy"\n}
612
- ])
601
+ %{$env:http_proxy = "http://proxy"\n},
602
+ %{$env:HTTP_PROXY = "http://proxy"\n},
603
+ ])
613
604
  end
614
605
 
615
606
  it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
616
607
  config[:https_proxy] = "https://proxy"
617
608
 
618
609
  cmd.lines.to_a[0..1].must_equal([
619
- %{$env:https_proxy = "https://proxy"\n},
620
- %{$env:HTTPS_PROXY = "https://proxy"\n}
621
- ])
610
+ %{$env:https_proxy = "https://proxy"\n},
611
+ %{$env:HTTPS_PROXY = "https://proxy"\n},
612
+ ])
622
613
  end
623
614
 
624
615
  it "exports all http proxy variables when both are set" do
@@ -626,20 +617,20 @@ describe Kitchen::Provisioner::ChefBase do
626
617
  config[:https_proxy] = "https://proxy"
627
618
 
628
619
  cmd.lines.to_a[0..3].must_equal([
629
- %{$env:http_proxy = "http://proxy"\n},
630
- %{$env:HTTP_PROXY = "http://proxy"\n},
631
- %{$env:https_proxy = "https://proxy"\n},
632
- %{$env:HTTPS_PROXY = "https://proxy"\n}
633
- ])
620
+ %{$env:http_proxy = "http://proxy"\n},
621
+ %{$env:HTTP_PROXY = "http://proxy"\n},
622
+ %{$env:https_proxy = "https://proxy"\n},
623
+ %{$env:HTTPS_PROXY = "https://proxy"\n},
624
+ ])
634
625
  end
635
626
 
636
627
  it "sets chef component dirs for deletion" do
637
- config[:root_path] = "\\route"
638
- dirs = %W[
628
+ config[:root_path] = '\\route'
629
+ dirs = %w{
639
630
  "\\route\\clients" "\\route\\cookbooks" "\\route\\data"
640
631
  "\\route\\data_bags" "\\route\\encrypted_data_bag_secret"
641
632
  "\\route\\environments" "\\route\\roles"
642
- ].join(", ")
633
+ }.join(", ")
643
634
 
644
635
  cmd.must_match regexify(%{$dirs = @(#{dirs})})
645
636
  end
@@ -653,7 +644,6 @@ describe Kitchen::Provisioner::ChefBase do
653
644
  end
654
645
 
655
646
  describe "#create_sandbox" do
656
-
657
647
  before do
658
648
  @root = Dir.mktmpdir
659
649
  config[:kitchen_root] = @root
@@ -668,7 +658,7 @@ describe Kitchen::Provisioner::ChefBase do
668
658
  end
669
659
 
670
660
  let(:provisioner) do
671
- Class.new(Kitchen::Provisioner::ChefBase) {
661
+ Class.new(Kitchen::Provisioner::ChefBase) do
672
662
  default_config :generic_rb, {}
673
663
 
674
664
  def create_sandbox
@@ -679,11 +669,10 @@ describe Kitchen::Provisioner::ChefBase do
679
669
  file.write(format_config_file(data))
680
670
  end
681
671
  end
682
- }.new(config).finalize_config!(instance)
672
+ end.new(config).finalize_config!(instance)
683
673
  end
684
674
 
685
675
  describe "json file" do
686
-
687
676
  let(:json) { JSON.parse(IO.read(sandbox_path("dna.json"))) }
688
677
 
689
678
  it "creates a json file with node attributes" do
@@ -694,10 +683,10 @@ describe Kitchen::Provisioner::ChefBase do
694
683
  end
695
684
 
696
685
  it "creates a json file with run_list" do
697
- config[:run_list] = %w[alpha bravo charlie]
686
+ config[:run_list] = %w{alpha bravo charlie}
698
687
  provisioner.create_sandbox
699
688
 
700
- json["run_list"].must_equal %w[alpha bravo charlie]
689
+ json["run_list"].must_equal %w{alpha bravo charlie}
701
690
  end
702
691
 
703
692
  it "creates a json file with an empty run_list" do
@@ -717,8 +706,8 @@ describe Kitchen::Provisioner::ChefBase do
717
706
  config[:run_list] = ["yo"]
718
707
  provisioner.create_sandbox
719
708
 
720
- logged_output.string.
721
- must_match debug_line(%|Creating dna.json from {:run_list=>["yo"]}|)
709
+ logged_output.string
710
+ .must_match debug_line(%(Creating dna.json from {:run_list=>["yo"]}))
722
711
  end
723
712
  end
724
713
 
@@ -728,9 +717,8 @@ describe Kitchen::Provisioner::ChefBase do
728
717
  sandbox_path("cache").directory?.must_equal true
729
718
  end
730
719
 
731
- %w[data data_bags environments nodes roles clients].each do |thing|
720
+ %w{data data_bags environments nodes roles clients}.each do |thing|
732
721
  describe "#{thing} files" do
733
-
734
722
  before do
735
723
  create_files_under("#{config[:kitchen_root]}/my_#{thing}")
736
724
  config[:"#{thing}_path"] = "#{config[:kitchen_root]}/my_#{thing}"
@@ -769,7 +757,6 @@ describe Kitchen::Provisioner::ChefBase do
769
757
  end
770
758
 
771
759
  describe "secret files" do
772
-
773
760
  before do
774
761
  config[:encrypted_data_bag_secret_key_path] =
775
762
  "#{config[:kitchen_root]}/my_secret"
@@ -807,22 +794,20 @@ describe Kitchen::Provisioner::ChefBase do
807
794
  end
808
795
 
809
796
  describe "cookbooks" do
810
-
811
797
  let(:kitchen_root) { config[:kitchen_root] }
812
798
 
813
799
  describe "with a cookbooks/ directory under kitchen_root" do
814
-
815
800
  it "copies cookbooks/" do
816
801
  create_cookbook("#{kitchen_root}/cookbooks/epache")
817
802
  create_cookbook("#{kitchen_root}/cookbooks/jahva")
818
803
  provisioner.create_sandbox
819
804
 
820
805
  sandbox_path("cookbooks/epache").directory?.must_equal true
821
- sandbox_path("cookbooks/epache/recipes/default.rb").
822
- file?.must_equal true
806
+ sandbox_path("cookbooks/epache/recipes/default.rb")
807
+ .file?.must_equal true
823
808
  sandbox_path("cookbooks/jahva").directory?.must_equal true
824
- sandbox_path("cookbooks/jahva/recipes/default.rb").
825
- file?.must_equal true
809
+ sandbox_path("cookbooks/jahva/recipes/default.rb")
810
+ .file?.must_equal true
826
811
  end
827
812
 
828
813
  it "copies from kitchen_root as cookbook if it contains metadata.rb" do
@@ -883,7 +868,6 @@ describe Kitchen::Provisioner::ChefBase do
883
868
  end
884
869
 
885
870
  describe "with a cookbook as the project" do
886
-
887
871
  before do
888
872
  File.open("#{kitchen_root}/metadata.rb", "wb") do |file|
889
873
  file.write("name 'wat'")
@@ -921,15 +905,14 @@ describe Kitchen::Provisioner::ChefBase do
921
905
  end
922
906
 
923
907
  describe "with no referenced cookbooks" do
924
-
925
908
  it "makes a fake cookbook" do
926
909
  name = File.basename(@root)
927
910
  provisioner.create_sandbox
928
911
 
929
912
  sandbox_path("cookbooks/#{name}").directory?.must_equal true
930
913
  sandbox_path("cookbooks/#{name}/metadata.rb").file?.must_equal true
931
- IO.read(sandbox_path("cookbooks/#{name}/metadata.rb")).
932
- must_equal %{name "#{name}"\n}
914
+ IO.read(sandbox_path("cookbooks/#{name}/metadata.rb"))
915
+ .must_equal %{name "#{name}"\n}
933
916
  end
934
917
 
935
918
  it "logs a warning" do
@@ -943,12 +926,11 @@ describe Kitchen::Provisioner::ChefBase do
943
926
  end
944
927
 
945
928
  describe "with a Policyfile under kitchen_root" do
946
-
947
929
  let(:policyfile_path) { "#{kitchen_root}/Policyfile.rb" }
948
930
  let(:policyfile_lock_path) { "#{kitchen_root}/Policyfile.lock.json" }
949
- let(:resolver) {
950
- stub(:compile => true, :resolve => true, :lockfile => policyfile_lock_path)
951
- }
931
+ let(:resolver) do
932
+ stub(compile: true, resolve: true, lockfile: policyfile_lock_path)
933
+ end
952
934
 
953
935
  describe "with the default name `Policyfile.rb`" do
954
936
  before do
@@ -986,7 +968,6 @@ POLICYFILE
986
968
  end
987
969
 
988
970
  describe "when the chef executable is in the PATH" do
989
-
990
971
  before do
991
972
  Kitchen::Provisioner::Chef::Policyfile.stubs(:load!)
992
973
  provisioner.stubs(:supports_policyfile?).returns(true)
@@ -1021,7 +1002,7 @@ POLICYFILE
1021
1002
 
1022
1003
  expected = {
1023
1004
  "policy_name" => "wat",
1024
- "policy_group" => "local"
1005
+ "policy_group" => "local",
1025
1006
  }
1026
1007
 
1027
1008
  dna_json_data.must_equal(expected)
@@ -1029,12 +1010,11 @@ POLICYFILE
1029
1010
  end
1030
1011
  end
1031
1012
  describe "with a custom policyfile_path" do
1032
-
1033
1013
  let(:config) do
1034
1014
  {
1035
- :policyfile_path => "foo-policy.rb",
1036
- :test_base_path => "/basist",
1037
- :kitchen_root => "/rooty"
1015
+ policyfile_path: "foo-policy.rb",
1016
+ test_base_path: "/basist",
1017
+ kitchen_root: "/rooty",
1038
1018
  }
1039
1019
  end
1040
1020
 
@@ -1045,7 +1025,6 @@ POLICYFILE
1045
1025
  end
1046
1026
 
1047
1027
  describe "when the policyfile exists" do
1048
-
1049
1028
  let(:policyfile_path) { "#{kitchen_root}/foo-policy.rb" }
1050
1029
  let(:policyfile_lock_path) { "#{kitchen_root}/foo-policy.lock.json" }
1051
1030
 
@@ -1075,10 +1054,10 @@ POLICYFILE
1075
1054
  end
1076
1055
 
1077
1056
  it "passes the correct path to the policyfile resolver" do
1078
- Kitchen::Provisioner::Chef::Policyfile.
1079
- expects(:new).
1080
- with(policyfile_path, instance_of(String), anything).
1081
- returns(resolver)
1057
+ Kitchen::Provisioner::Chef::Policyfile
1058
+ .expects(:new)
1059
+ .with(policyfile_path, instance_of(String), anything)
1060
+ .returns(resolver)
1082
1061
 
1083
1062
  Kitchen::Provisioner::Chef::Policyfile.stubs(:load!)
1084
1063
  resolver.expects(:compile)
@@ -1088,11 +1067,9 @@ POLICYFILE
1088
1067
  end
1089
1068
  end
1090
1069
  describe "when the policyfile doesn't exist" do
1091
-
1092
1070
  it "raises a UserError" do
1093
1071
  proc { provisioner.create_sandbox }.must_raise Kitchen::UserError
1094
1072
  end
1095
-
1096
1073
  end
1097
1074
  describe "when the policyfile lock doesn't exist" do
1098
1075
  before do
@@ -1112,12 +1089,11 @@ POLICYFILE
1112
1089
  end
1113
1090
  end
1114
1091
  describe "with a fallback policyfile" do
1115
-
1116
1092
  let(:config) do
1117
1093
  {
1118
- :policyfile => "foo-policy.rb",
1119
- :test_base_path => "/basist",
1120
- :kitchen_root => "/rooty"
1094
+ policyfile: "foo-policy.rb",
1095
+ test_base_path: "/basist",
1096
+ kitchen_root: "/rooty",
1121
1097
  }
1122
1098
  end
1123
1099
 
@@ -1128,7 +1104,6 @@ POLICYFILE
1128
1104
  end
1129
1105
 
1130
1106
  describe "when the policyfile exists" do
1131
-
1132
1107
  let(:policyfile_path) { "#{kitchen_root}/foo-policy.rb" }
1133
1108
  let(:policyfile_lock_path) { "#{kitchen_root}/foo-policy.lock.json" }
1134
1109
 
@@ -1158,10 +1133,10 @@ POLICYFILE
1158
1133
  end
1159
1134
 
1160
1135
  it "passes the correct path to the policyfile resolver" do
1161
- Kitchen::Provisioner::Chef::Policyfile.
1162
- expects(:new).
1163
- with(policyfile_path, instance_of(String), anything).
1164
- returns(resolver)
1136
+ Kitchen::Provisioner::Chef::Policyfile
1137
+ .expects(:new)
1138
+ .with(policyfile_path, instance_of(String), anything)
1139
+ .returns(resolver)
1165
1140
 
1166
1141
  Kitchen::Provisioner::Chef::Policyfile.stubs(:load!)
1167
1142
  resolver.expects(:compile)
@@ -1171,18 +1146,15 @@ POLICYFILE
1171
1146
  end
1172
1147
  end
1173
1148
  describe "when the policyfile doesn't exist" do
1174
-
1175
1149
  it "raises a UserError" do
1176
1150
  proc { provisioner.create_sandbox }.must_raise Kitchen::UserError
1177
1151
  end
1178
-
1179
1152
  end
1180
1153
  end
1181
1154
  end
1182
1155
 
1183
1156
  describe "with a Berksfile under kitchen_root" do
1184
-
1185
- let(:resolver) { stub(:resolve => true) }
1157
+ let(:resolver) { stub(resolve: true) }
1186
1158
 
1187
1159
  before do
1188
1160
  File.open("#{kitchen_root}/Berksfile", "wb") do |file|
@@ -1222,8 +1194,7 @@ POLICYFILE
1222
1194
  end
1223
1195
 
1224
1196
  describe "with a Cheffile under kitchen_root" do
1225
-
1226
- let(:resolver) { stub(:resolve => true) }
1197
+ let(:resolver) { stub(resolve: true) }
1227
1198
 
1228
1199
  before do
1229
1200
  File.open("#{kitchen_root}/Cheffile", "wb") do |file|
@@ -1261,7 +1232,6 @@ POLICYFILE
1261
1232
  end
1262
1233
 
1263
1234
  describe "filtering cookbooks files" do
1264
-
1265
1235
  it "retains all useful cookbook files" do
1266
1236
  create_full_cookbook("#{kitchen_root}/cookbooks/full")
1267
1237
  provisioner.create_sandbox
@@ -1272,10 +1242,10 @@ POLICYFILE
1272
1242
  end
1273
1243
 
1274
1244
  it "strips extra cookbook files" do
1275
- extras = %w[
1245
+ extras = %w{
1276
1246
  .gitignore tmp/librarian chefignore .git/info/excludes
1277
1247
  cookbooks/another/metadata.rb CONTRIBUTING.md metadata.py
1278
- ]
1248
+ }
1279
1249
 
1280
1250
  create_full_cookbook("#{kitchen_root}/cookbooks/full")
1281
1251
  extras.each do |file|
@@ -1298,7 +1268,6 @@ POLICYFILE
1298
1268
  end
1299
1269
 
1300
1270
  describe "Chef config files" do
1301
-
1302
1271
  let(:file) do
1303
1272
  IO.read(sandbox_path("generic.rb")).lines.map(&:chomp)
1304
1273
  end
@@ -1310,7 +1279,6 @@ POLICYFILE
1310
1279
  end
1311
1280
 
1312
1281
  describe "defaults" do
1313
-
1314
1282
  before { provisioner.create_sandbox }
1315
1283
 
1316
1284
  it "sets node_name to the instance name" do
@@ -1378,9 +1346,9 @@ POLICYFILE
1378
1346
 
1379
1347
  it "supports overwriting defaults" do
1380
1348
  config[:generic_rb] = {
1381
- :node_name => "eagles",
1382
- :user_path => "/a/b/c/u",
1383
- :chef_server_url => "https://whereever.io"
1349
+ node_name: "eagles",
1350
+ user_path: "/a/b/c/u",
1351
+ chef_server_url: "https://whereever.io",
1384
1352
  }
1385
1353
  provisioner.create_sandbox
1386
1354
 
@@ -1391,7 +1359,7 @@ POLICYFILE
1391
1359
 
1392
1360
  it " supports adding new configuration" do
1393
1361
  config[:generic_rb] = {
1394
- :dark_secret => "golang"
1362
+ dark_secret: "golang",
1395
1363
  }
1396
1364
  provisioner.create_sandbox
1397
1365
 
@@ -1400,18 +1368,18 @@ POLICYFILE
1400
1368
  end
1401
1369
 
1402
1370
  def create_cookbook(path)
1403
- %w[metadata.rb attributes/all.rb recipes/default.rb].each do |file|
1371
+ %w{metadata.rb attributes/all.rb recipes/default.rb}.each do |file|
1404
1372
  create_file(File.join(path, file))
1405
1373
  end
1406
1374
  end
1407
1375
 
1408
1376
  def full_cookbook_files
1409
- %w[
1377
+ %w{
1410
1378
  README.org metadata.rb attributes/all.rb definitions/def.rb
1411
1379
  files/default/config.conf libraries/one.rb libraries/two.rb
1412
1380
  providers/sweet.rb recipes/default.rb resources/sweet.rb
1413
1381
  templates/ubuntu/12.04/nginx.conf.erb
1414
- ]
1382
+ }
1415
1383
  end
1416
1384
 
1417
1385
  def create_full_cookbook(path)
@@ -1439,11 +1407,11 @@ POLICYFILE
1439
1407
  end
1440
1408
 
1441
1409
  def info_line(msg)
1442
- %r{^I, .* : #{Regexp.escape(msg)}$}
1410
+ /^I, .* : #{Regexp.escape(msg)}$/
1443
1411
  end
1444
1412
 
1445
1413
  def debug_line(msg)
1446
- %r{^D, .* : #{Regexp.escape(msg)}$}
1414
+ /^D, .* : #{Regexp.escape(msg)}$/
1447
1415
  end
1448
1416
  end
1449
1417