test-kitchen 1.23.3 → 1.23.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. checksums.yaml +4 -4
  2. data/lib/kitchen/version.rb +1 -1
  3. data/support/chef-client-zero.rb +1 -1
  4. metadata +5 -324
  5. data/.gitattributes +0 -3
  6. data/.github/ISSUE_TEMPLATE.md +0 -56
  7. data/.github/lock.yml +0 -1
  8. data/.gitignore +0 -38
  9. data/.gitmodules +0 -0
  10. data/.kitchen.appveyor.yml +0 -25
  11. data/.kitchen.dokken.yml +0 -31
  12. data/.kitchen.proxy.yml +0 -27
  13. data/.rubocop.yml +0 -5
  14. data/.travis.yml +0 -57
  15. data/.yardopts +0 -3
  16. data/Berksfile +0 -3
  17. data/CHANGELOG.md +0 -1510
  18. data/CONTRIBUTING.md +0 -14
  19. data/ECOSYSTEM.md +0 -93
  20. data/Gemfile +0 -40
  21. data/Gemfile.proxy_tests +0 -4
  22. data/Guardfile +0 -42
  23. data/MAINTAINERS.md +0 -29
  24. data/README.md +0 -138
  25. data/RELEASE_NOTES.md +0 -167
  26. data/Rakefile +0 -77
  27. data/appveyor.yml +0 -47
  28. data/docs/CONTRIBUTING.md +0 -8
  29. data/docs/LICENSE +0 -22
  30. data/docs/README.md +0 -78
  31. data/docs/archetypes/default.md +0 -6
  32. data/docs/config.toml +0 -36
  33. data/docs/content/docs/_index.md +0 -5
  34. data/docs/content/docs/drivers/_index.md +0 -27
  35. data/docs/content/docs/drivers/azurerm.md +0 -44
  36. data/docs/content/docs/drivers/vagrant.md +0 -39
  37. data/docs/content/docs/getting-started/00-introduction.md +0 -14
  38. data/docs/content/docs/getting-started/01-installing.md +0 -64
  39. data/docs/content/docs/getting-started/02-getting-help.md +0 -59
  40. data/docs/content/docs/getting-started/03-creating-cookbook.md +0 -46
  41. data/docs/content/docs/getting-started/04-kitchen-yml.md +0 -56
  42. data/docs/content/docs/getting-started/05-instances.md +0 -79
  43. data/docs/content/docs/getting-started/06-writing-recipe.md +0 -21
  44. data/docs/content/docs/getting-started/07-running-converge.md +0 -134
  45. data/docs/content/docs/getting-started/08-manually-verifying.md +0 -55
  46. data/docs/content/docs/getting-started/09-writing-test.md +0 -49
  47. data/docs/content/docs/getting-started/10-running-verify.md +0 -120
  48. data/docs/content/docs/getting-started/11-running-test.md +0 -168
  49. data/docs/content/docs/getting-started/12-adding-platform.md +0 -206
  50. data/docs/content/docs/getting-started/13-adding-feature.md +0 -30
  51. data/docs/content/docs/getting-started/14-adding-suite.md +0 -60
  52. data/docs/content/docs/getting-started/15-adding-test.md +0 -66
  53. data/docs/content/docs/getting-started/16-adding-recipe.md +0 -53
  54. data/docs/content/docs/getting-started/17-excluding-platforms.md +0 -101
  55. data/docs/content/docs/getting-started/18-next-steps.md +0 -23
  56. data/docs/content/docs/getting-started/_index.md +0 -5
  57. data/docs/content/docs/provisioners/_index.md +0 -36
  58. data/docs/content/docs/provisioners/chef.md +0 -69
  59. data/docs/content/docs/provisioners/shell.md +0 -31
  60. data/docs/content/docs/reference/_index.md +0 -5
  61. data/docs/content/docs/reference/configuration.md +0 -53
  62. data/docs/content/docs/reference/examples.md +0 -97
  63. data/docs/content/docs/reference/faq.md +0 -58
  64. data/docs/content/docs/reference/fixtures.md +0 -32
  65. data/docs/content/docs/reference/glossary.md +0 -34
  66. data/docs/content/docs/reference/lifecycle-hooks.md +0 -68
  67. data/docs/content/docs/reference/reboots.md +0 -24
  68. data/docs/content/docs/verifiers/_index.md +0 -14
  69. data/docs/content/docs/verifiers/inspec.md +0 -44
  70. data/docs/content/docs/verifiers/serverspec.md +0 -20
  71. data/docs/static/images/chef-logo.png +0 -0
  72. data/docs/static/images/chef-logo.svg +0 -1
  73. data/docs/static/images/github-banner.png +0 -0
  74. data/docs/static/images/github-banner.svg +0 -71
  75. data/docs/static/images/kitchen-logo.png +0 -0
  76. data/docs/static/images/logo-block.svg +0 -222
  77. data/docs/static/images/logo.png +0 -0
  78. data/docs/static/images/logos-group.png +0 -0
  79. data/docs/static/images/terminal-1.png +0 -0
  80. data/docs/static/images/terminal-1.svg +0 -589
  81. data/docs/static/images/terminal-2.png +0 -0
  82. data/docs/static/images/terminal-2.svg +0 -235
  83. data/docs/static/images/terminal-3.png +0 -0
  84. data/docs/static/images/terminal-3.svg +0 -439
  85. data/docs/static/index.html +0 -59
  86. data/docs/static/javascripts/all.js +0 -348
  87. data/docs/static/javascripts/vendor/foundation.min.js +0 -4
  88. data/docs/static/javascripts/vendor/jquery.min.js +0 -5
  89. data/docs/static/javascripts/vendor/what-input.js +0 -336
  90. data/docs/static/stylesheets/site.css +0 -4667
  91. data/docs/themes/kitchen/layouts/_default/baseof.html +0 -53
  92. data/docs/themes/kitchen/layouts/_default/list.html +0 -4
  93. data/docs/themes/kitchen/layouts/_default/redirect.html +0 -10
  94. data/docs/themes/kitchen/layouts/_default/single.html +0 -6
  95. data/docs/themes/kitchen/layouts/partials/core/head.html +0 -6
  96. data/docs/themes/kitchen/layouts/partials/kitchen/footer.html +0 -18
  97. data/docs/themes/kitchen/layouts/partials/kitchen/head.html +0 -4
  98. data/docs/themes/kitchen/layouts/partials/kitchen/header.html +0 -26
  99. data/docs/themes/kitchen/layouts/partials/search-docs.html +0 -3
  100. data/docs/themes/kitchen/layouts/partials/sidebar.html +0 -33
  101. data/docs/themes/kitchen/layouts/shortcodes/button.html +0 -1
  102. data/docs/themes/kitchen/layouts/shortcodes/codeblock.html +0 -8
  103. data/docs/themes/kitchen/layouts/shortcodes/cta.html +0 -5
  104. data/docs/themes/kitchen/layouts/shortcodes/danger.html +0 -1
  105. data/docs/themes/kitchen/layouts/shortcodes/example_fqdn.html +0 -1
  106. data/docs/themes/kitchen/layouts/shortcodes/info.html +0 -1
  107. data/docs/themes/kitchen/layouts/shortcodes/ol-styled.html +0 -3
  108. data/docs/themes/kitchen/layouts/shortcodes/success.html +0 -1
  109. data/docs/themes/kitchen/layouts/shortcodes/tip.html +0 -1
  110. data/docs/themes/kitchen/layouts/shortcodes/warning.html +0 -1
  111. data/docs/themes/kitchen/static/css/kitchen.css +0 -10
  112. data/docs/themes/kitchen/static/css/kitchen.css.map +0 -7
  113. data/docs/themes/kitchen/static/fonts/Muli-Bold.ttf +0 -0
  114. data/docs/themes/kitchen/static/fonts/Muli-Regular.ttf +0 -0
  115. data/docs/themes/kitchen/static/fonts/Muli-SemiBold.ttf +0 -0
  116. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.eot +0 -0
  117. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.svg +0 -1104
  118. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.ttf +0 -0
  119. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff +0 -0
  120. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff2 +0 -0
  121. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.eot +0 -0
  122. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.svg +0 -372
  123. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.ttf +0 -0
  124. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff +0 -0
  125. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff2 +0 -0
  126. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.eot +0 -0
  127. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.svg +0 -1896
  128. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.ttf +0 -0
  129. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff +0 -0
  130. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff2 +0 -0
  131. data/docs/themes/kitchen/static/images/chef-logo-light.svg +0 -36
  132. data/docs/themes/kitchen/static/images/chef-logo-white.svg +0 -38
  133. data/docs/themes/kitchen/static/images/chef-logo.svg +0 -37
  134. data/docs/themes/kitchen/static/images/favicon.ico +0 -0
  135. data/docs/themes/kitchen/static/js/scripts-all.js +0 -7
  136. data/docs/themes/kitchen/static/js/source/chef-hugo.js +0 -116
  137. data/docs/themes/kitchen/static/js/source/omnitruck.js +0 -82
  138. data/docs/themes/kitchen/static/js/source/segment.js +0 -52
  139. data/docs/themes/kitchen/static/sass/_buttons.scss +0 -161
  140. data/docs/themes/kitchen/static/sass/_core.scss +0 -24
  141. data/docs/themes/kitchen/static/sass/_forms.scss +0 -14
  142. data/docs/themes/kitchen/static/sass/_mixins.scss +0 -133
  143. data/docs/themes/kitchen/static/sass/_typography.scss +0 -34
  144. data/docs/themes/kitchen/static/sass/_variables.scss +0 -82
  145. data/docs/themes/kitchen/static/sass/kitchen.scss +0 -7
  146. data/docs/themes/kitchen/static/sass/kitchen/_footer.scss +0 -50
  147. data/docs/themes/kitchen/static/sass/kitchen/_header.scss +0 -187
  148. data/docs/themes/kitchen/static/sass/kitchen/_homepage.scss +0 -27
  149. data/docs/themes/kitchen/static/sass/kitchen/_utility-bar.scss +0 -173
  150. data/docs/themes/kitchen/static/sass/partials/_alerts.scss +0 -32
  151. data/docs/themes/kitchen/static/sass/partials/_bg.scss +0 -19
  152. data/docs/themes/kitchen/static/sass/partials/_blurbs.scss +0 -25
  153. data/docs/themes/kitchen/static/sass/partials/_callout.scss +0 -15
  154. data/docs/themes/kitchen/static/sass/partials/_cards.scss +0 -54
  155. data/docs/themes/kitchen/static/sass/partials/_dropdown.scss +0 -77
  156. data/docs/themes/kitchen/static/sass/partials/_grid.scss +0 -87
  157. data/docs/themes/kitchen/static/sass/partials/_padding.scss +0 -73
  158. data/docs/themes/kitchen/static/sass/partials/_sidebar.scss +0 -71
  159. data/docs/themes/kitchen/static/sass/partials/_tabs.scss +0 -125
  160. data/docs/themes/kitchen/static/sass/typography/_chroma.scss +0 -366
  161. data/docs/themes/kitchen/static/sass/typography/_code.scss +0 -72
  162. data/docs/themes/kitchen/static/sass/typography/_headers.scss +0 -90
  163. data/docs/themes/kitchen/static/sass/typography/_links.scss +0 -127
  164. data/docs/themes/kitchen/static/sass/typography/_lists.scss +0 -155
  165. data/docs/themes/kitchen/static/sass/typography/_prose.scss +0 -29
  166. data/docs/themes/kitchen/static/sass/typography/_text.scss +0 -221
  167. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_animated.scss +0 -20
  168. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_bordered-pulled.scss +0 -20
  169. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_core.scss +0 -16
  170. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_fixed-width.scss +0 -6
  171. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_icons.scss +0 -992
  172. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_larger.scss +0 -23
  173. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_list.scss +0 -18
  174. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_mixins.scss +0 -57
  175. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_rotated-flipped.scss +0 -23
  176. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_screen-reader.scss +0 -5
  177. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_stacked.scss +0 -31
  178. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_variables.scss +0 -1005
  179. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-brands.scss +0 -21
  180. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-regular.scss +0 -22
  181. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-solid.scss +0 -23
  182. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fontawesome.scss +0 -16
  183. data/docs/themes/kitchen/theme.toml +0 -8
  184. data/features/kitchen_action_commands.feature +0 -164
  185. data/features/kitchen_command.feature +0 -16
  186. data/features/kitchen_console_command.feature +0 -35
  187. data/features/kitchen_defaults.feature +0 -38
  188. data/features/kitchen_diagnose_command.feature +0 -96
  189. data/features/kitchen_help_command.feature +0 -16
  190. data/features/kitchen_init_command.feature +0 -254
  191. data/features/kitchen_list_command.feature +0 -140
  192. data/features/kitchen_login_command.feature +0 -62
  193. data/features/kitchen_sink_command.feature +0 -30
  194. data/features/kitchen_test_command.feature +0 -88
  195. data/features/step_definitions/gem_steps.rb +0 -24
  196. data/features/step_definitions/git_steps.rb +0 -5
  197. data/features/step_definitions/output_steps.rb +0 -5
  198. data/features/support/env.rb +0 -74
  199. data/spec/kitchen/base64_stream_spec.rb +0 -74
  200. data/spec/kitchen/cli_spec.rb +0 -54
  201. data/spec/kitchen/collection_spec.rb +0 -76
  202. data/spec/kitchen/color_spec.rb +0 -51
  203. data/spec/kitchen/config_spec.rb +0 -434
  204. data/spec/kitchen/configurable_spec.rb +0 -1113
  205. data/spec/kitchen/data_munger_spec.rb +0 -2800
  206. data/spec/kitchen/diagnostic_spec.rb +0 -128
  207. data/spec/kitchen/driver/base_spec.rb +0 -132
  208. data/spec/kitchen/driver/dummy_spec.rb +0 -193
  209. data/spec/kitchen/driver/exec_spec.rb +0 -75
  210. data/spec/kitchen/driver/proxy_spec.rb +0 -127
  211. data/spec/kitchen/driver/ssh_base_spec.rb +0 -1136
  212. data/spec/kitchen/driver_spec.rb +0 -106
  213. data/spec/kitchen/errors_spec.rb +0 -317
  214. data/spec/kitchen/instance_spec.rb +0 -1372
  215. data/spec/kitchen/lazy_hash_spec.rb +0 -113
  216. data/spec/kitchen/lifecycle_hooks_spec.rb +0 -171
  217. data/spec/kitchen/loader/yaml_spec.rb +0 -787
  218. data/spec/kitchen/logger_spec.rb +0 -425
  219. data/spec/kitchen/logging_spec.rb +0 -56
  220. data/spec/kitchen/login_command_spec.rb +0 -67
  221. data/spec/kitchen/metadata_chopper_spec.rb +0 -79
  222. data/spec/kitchen/platform_spec.rb +0 -88
  223. data/spec/kitchen/provisioner/base_spec.rb +0 -393
  224. data/spec/kitchen/provisioner/chef/policyfile_spec.rb +0 -140
  225. data/spec/kitchen/provisioner/chef_apply_spec.rb +0 -131
  226. data/spec/kitchen/provisioner/chef_base_spec.rb +0 -1565
  227. data/spec/kitchen/provisioner/chef_solo_spec.rb +0 -602
  228. data/spec/kitchen/provisioner/chef_zero_spec.rb +0 -1013
  229. data/spec/kitchen/provisioner/dummy_spec.rb +0 -96
  230. data/spec/kitchen/provisioner/shell_spec.rb +0 -623
  231. data/spec/kitchen/provisioner_spec.rb +0 -101
  232. data/spec/kitchen/shell_out_spec.rb +0 -146
  233. data/spec/kitchen/ssh_spec.rb +0 -584
  234. data/spec/kitchen/state_file_spec.rb +0 -122
  235. data/spec/kitchen/suite_spec.rb +0 -61
  236. data/spec/kitchen/transport/base_spec.rb +0 -140
  237. data/spec/kitchen/transport/exec_spec.rb +0 -79
  238. data/spec/kitchen/transport/ssh_spec.rb +0 -1317
  239. data/spec/kitchen/transport/winrm_spec.rb +0 -1320
  240. data/spec/kitchen/transport_spec.rb +0 -106
  241. data/spec/kitchen/util_spec.rb +0 -250
  242. data/spec/kitchen/verifier/base_spec.rb +0 -346
  243. data/spec/kitchen/verifier/busser_spec.rb +0 -580
  244. data/spec/kitchen/verifier/dummy_spec.rb +0 -96
  245. data/spec/kitchen/verifier/shell_spec.rb +0 -157
  246. data/spec/kitchen/verifier_spec.rb +0 -114
  247. data/spec/kitchen_spec.rb +0 -112
  248. data/spec/spec_helper.rb +0 -110
  249. data/spec/support/powershell_max_size_spec.rb +0 -39
  250. data/test-kitchen.gemspec +0 -49
  251. data/test/cookbooks/test_cookbook/metadata.rb +0 -6
  252. data/test/cookbooks/test_cookbook/recipes/default.rb +0 -1
  253. data/test/integration/default/default_spec.rb +0 -3
  254. data/testing_windows.md +0 -38
@@ -1,113 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
- #
5
- # Copyright (C) 2013, Fletcher Nichol
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require_relative "../spec_helper"
20
-
21
- require "kitchen/lazy_hash"
22
-
23
- describe Kitchen::LazyHash do
24
- let(:context) do
25
- stub(color: "blue", metal: "heavy")
26
- end
27
-
28
- let(:hash_obj) do
29
- {
30
- shed_color: ->(c) { c.color },
31
- barn: "locked",
32
- genre: proc { |c| "#{c.metal} metal" },
33
- }
34
- end
35
-
36
- describe "#[]" do
37
- it "returns regular values for keys" do
38
- Kitchen::LazyHash.new(hash_obj, context)[:barn].must_equal "locked"
39
- end
40
-
41
- it "invokes call on values that are lambdas" do
42
- Kitchen::LazyHash.new(hash_obj, context)[:shed_color].must_equal "blue"
43
- end
44
-
45
- it "invokes call on values that are Procs" do
46
- Kitchen::LazyHash.new(hash_obj, context)[:genre].must_equal "heavy metal"
47
- end
48
- end
49
-
50
- describe "#fetch" do
51
- it "returns regular hash values for keys" do
52
- Kitchen::LazyHash.new(hash_obj, context).fetch(:barn).must_equal "locked"
53
- end
54
-
55
- it "invokes call on values that are lambdas" do
56
- Kitchen::LazyHash.new(hash_obj, context)
57
- .fetch(:shed_color).must_equal "blue"
58
- end
59
-
60
- it "invokes call on values that are Procs" do
61
- Kitchen::LazyHash.new(hash_obj, context)
62
- .fetch(:genre).must_equal "heavy metal"
63
- end
64
-
65
- it "uses a default value for unset values" do
66
- Kitchen::LazyHash.new(hash_obj, context)
67
- .fetch(:nope, "candy").must_equal "candy"
68
- end
69
-
70
- it "uses a block for unset values" do
71
- Kitchen::LazyHash.new(hash_obj, context)
72
- .fetch(:nope) { |key| "#{key} is costly" }.must_equal "nope is costly"
73
- end
74
- end
75
-
76
- describe "#to_hash" do
77
- it "invokes any callable values and returns a Hash object" do
78
- converted = Kitchen::LazyHash.new(hash_obj, context).to_hash
79
-
80
- converted.must_be_instance_of Hash
81
- converted.fetch(:shed_color).must_equal "blue"
82
- converted.fetch(:barn).must_equal "locked"
83
- converted.fetch(:genre).must_equal "heavy metal"
84
- end
85
- end
86
-
87
- describe "select" do
88
- it "calls Procs when appropriate" do
89
- Kitchen::LazyHash.new(hash_obj, context).select { |_, _| true }
90
- .must_equal shed_color: "blue", barn: "locked", genre: "heavy metal"
91
- end
92
- end
93
-
94
- describe "enumerable" do
95
- it "is an Enumerable" do
96
- assert Kitchen::LazyHash.new(hash_obj, context).is_a? Enumerable
97
- end
98
-
99
- it "returns an Enumerator from each() if no block given" do
100
- e = Kitchen::LazyHash.new(hash_obj, context).each
101
- e.is_a? Enumerator
102
- e.next.must_equal [:shed_color, "blue"]
103
- e.next.must_equal [:barn, "locked"]
104
- e.next.must_equal [:genre, "heavy metal"]
105
- end
106
-
107
- it "yields each item to the block if a block is given to each()" do
108
- items = []
109
- Kitchen::LazyHash.new(hash_obj, context).each { |i| items << i }
110
- items.must_equal [[:shed_color, "blue"], [:barn, "locked"], [:genre, "heavy metal"]]
111
- end
112
- end
113
- end
@@ -1,171 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Noah Kantrowitz <noah@coderanger.net>
4
- #
5
- # Copyright (C) 2018, Noah Kantrowitz
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require_relative "../spec_helper"
20
-
21
- require "kitchen/errors"
22
- require "kitchen/lifecycle_hooks"
23
-
24
- describe Kitchen::LifecycleHooks do
25
- let(:suite) { mock("suite").tap { |i| i.stubs(name: "default") } }
26
- let(:platform) { mock("platform").tap { |i| i.stubs(name: "toaster-1.0") } }
27
- let(:state_file) { mock("state_file").tap { |s| s.stubs(read: { hostname: "localhost" }) } }
28
- let(:connection) { mock("connection") }
29
- let(:transport) { mock("transport").tap { |t| t.stubs(:connection).with({ hostname: "localhost" }).returns(connection) } }
30
- let(:last_action) { :create }
31
- let(:instance) { mock("instance").tap { |i| i.stubs(name: "default-toaster-10", transport: transport, last_action: last_action, suite: suite, platform: platform) } }
32
- let(:config) { { kitchen_root: "/kitchen" } }
33
- let(:lifecycle_hooks) { Kitchen::LifecycleHooks.new(config).tap { |lh| lh.finalize_config!(instance) } }
34
-
35
- def run_lifecycle_hooks
36
- lifecycle_hooks.run_with_hooks(:create, state_file) {}
37
- end
38
-
39
- # Pull this out because it's used in a bunch of tests.
40
- STANDARD_LOCAL_OPTIONS = {
41
- cwd: "/kitchen",
42
- environment: {
43
- "KITCHEN_INSTANCE_NAME" => "default-toaster-10",
44
- "KITCHEN_SUITE_NAME" => "default",
45
- "KITCHEN_PLATFORM_NAME" => "toaster-1.0",
46
- "KITCHEN_INSTANCE_HOSTNAME" => "localhost",
47
- },
48
- }.freeze
49
-
50
- it "runs a single local command" do
51
- config.update(post_create: ["echo foo"])
52
- lifecycle_hooks.expects(:run_command).with("echo foo", STANDARD_LOCAL_OPTIONS)
53
- run_lifecycle_hooks
54
- end
55
-
56
- it "runs multiple local commands" do
57
- config.update(post_create: ["echo foo", { local: "echo bar" }])
58
- lifecycle_hooks.expects(:run_command).with("echo foo", STANDARD_LOCAL_OPTIONS)
59
- lifecycle_hooks.expects(:run_command).with("echo bar", STANDARD_LOCAL_OPTIONS)
60
- run_lifecycle_hooks
61
- end
62
-
63
- it "runs multiple local hooks" do
64
- config.update(pre_create: ["echo foo"], post_create: ["echo bar"])
65
- lifecycle_hooks.expects(:run_command).with("echo foo", STANDARD_LOCAL_OPTIONS)
66
- lifecycle_hooks.expects(:run_command).with("echo bar", STANDARD_LOCAL_OPTIONS)
67
- run_lifecycle_hooks
68
- end
69
-
70
- it "runs a local command with a user option" do
71
- config.update(post_create: [{ local: "echo foo", user: "bar" }])
72
- lifecycle_hooks.expects(:run_command).with("echo foo", {
73
- cwd: "/kitchen",
74
- user: "bar",
75
- environment: {
76
- "KITCHEN_INSTANCE_NAME" => "default-toaster-10",
77
- "KITCHEN_SUITE_NAME" => "default",
78
- "KITCHEN_PLATFORM_NAME" => "toaster-1.0",
79
- "KITCHEN_INSTANCE_HOSTNAME" => "localhost",
80
- },
81
- })
82
- run_lifecycle_hooks
83
- end
84
-
85
- it "runs a local command with environment options" do
86
- config.update(post_create: [{ local: "echo foo", environment: { FOO: "one", BAR: "two" } }])
87
- lifecycle_hooks.expects(:run_command).with("echo foo", {
88
- cwd: "/kitchen",
89
- environment: {
90
- "FOO" => "one",
91
- "BAR" => "two",
92
- "KITCHEN_INSTANCE_NAME" => "default-toaster-10",
93
- "KITCHEN_SUITE_NAME" => "default",
94
- "KITCHEN_PLATFORM_NAME" => "toaster-1.0",
95
- "KITCHEN_INSTANCE_HOSTNAME" => "localhost",
96
- },
97
- })
98
- run_lifecycle_hooks
99
- end
100
-
101
- it "runs a local command with a relative cwd option" do
102
- config.update(post_create: [{ local: "echo foo", cwd: "test" }])
103
- lifecycle_hooks.expects(:run_command).with("echo foo", {
104
- cwd: os_safe_root_path("/kitchen/test"),
105
- environment: {
106
- "KITCHEN_INSTANCE_NAME" => "default-toaster-10",
107
- "KITCHEN_SUITE_NAME" => "default",
108
- "KITCHEN_PLATFORM_NAME" => "toaster-1.0",
109
- "KITCHEN_INSTANCE_HOSTNAME" => "localhost",
110
- },
111
- })
112
- run_lifecycle_hooks
113
- end
114
-
115
- it "runs a local command with an absolute cwd option" do
116
- config.update(post_create: [{ local: "echo foo", cwd: "/test" }])
117
- lifecycle_hooks.expects(:run_command).with("echo foo", {
118
- cwd: os_safe_root_path("/test"),
119
- environment: {
120
- "KITCHEN_INSTANCE_NAME" => "default-toaster-10",
121
- "KITCHEN_SUITE_NAME" => "default",
122
- "KITCHEN_PLATFORM_NAME" => "toaster-1.0",
123
- "KITCHEN_INSTANCE_HOSTNAME" => "localhost",
124
- },
125
- })
126
- run_lifecycle_hooks
127
- end
128
-
129
- it "runs a single remote command" do
130
- config.update(post_create: [{ remote: "echo foo" }])
131
- lifecycle_hooks.expects(:run_command).never
132
- connection.expects(:execute).with("echo foo")
133
- run_lifecycle_hooks
134
- end
135
-
136
- it "rejects unknown hook targets" do
137
- config.update(post_create: [{ banana: "echo foo" }])
138
- lifecycle_hooks.expects(:run_command).never
139
- proc { run_lifecycle_hooks }.must_raise Kitchen::UserError
140
- end
141
-
142
- it "runs mixed local and remote commands" do
143
- config.update(post_create: ["echo foo", { local: "echo bar" }, { remote: "echo baz" }])
144
- lifecycle_hooks.expects(:run_command).with("echo foo", STANDARD_LOCAL_OPTIONS)
145
- lifecycle_hooks.expects(:run_command).with("echo bar", STANDARD_LOCAL_OPTIONS)
146
- connection.expects(:execute).with("echo baz")
147
- run_lifecycle_hooks
148
- end
149
-
150
- describe "with no last_action" do
151
- let(:last_action) { nil }
152
-
153
- it "runs local commands" do
154
- config.update(post_create: [{ local: "echo foo" }])
155
- lifecycle_hooks.expects(:run_command).with("echo foo", STANDARD_LOCAL_OPTIONS)
156
- run_lifecycle_hooks
157
- end
158
-
159
- it "fails on remote commands" do
160
- config.update(post_create: [{ remote: "echo foo" }])
161
- lifecycle_hooks.expects(:run_command).never
162
- proc { run_lifecycle_hooks }.must_raise Kitchen::UserError
163
- end
164
-
165
- it "ignores skippable remote commands" do
166
- config.update(post_create: [{ remote: "echo foo", skippable: true }])
167
- lifecycle_hooks.expects(:run_command).never
168
- run_lifecycle_hooks
169
- end
170
- end
171
- end
@@ -1,787 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
- #
5
- # Copyright (C) 2013, Fletcher Nichol
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require_relative "../../spec_helper"
20
-
21
- require "kitchen/errors"
22
- require "kitchen/util"
23
- require "kitchen/loader/yaml"
24
-
25
- class Yamled
26
- attr_accessor :foo
27
- end
28
-
29
- describe Kitchen::Loader::YAML do
30
- let(:loader) do
31
- Kitchen::Loader::YAML.new(project_config: "/tmp/.kitchen.yml")
32
- end
33
-
34
- before do
35
- FakeFS.activate!
36
- FileUtils.mkdir_p("/tmp")
37
- end
38
-
39
- after do
40
- FakeFS.deactivate!
41
- FakeFS::FileSystem.clear
42
- end
43
-
44
- describe ".initialize" do
45
- it "sets project_config based on Dir.pwd by default" do
46
- stub_file(File.join(Dir.pwd, "kitchen.yml"), {})
47
- loader = Kitchen::Loader::YAML.new
48
-
49
- loader.diagnose[:project_config][:filename]
50
- .must_equal File.expand_path(File.join(Dir.pwd, "kitchen.yml"))
51
- end
52
-
53
- it "when kitchen.yml not present, falls back to .kitchen.yml" do
54
- stub_file(File.join(Dir.pwd, ".kitchen.yml"), {})
55
- loader = Kitchen::Loader::YAML.new
56
-
57
- loader.diagnose[:project_config][:filename]
58
- .must_equal File.expand_path(File.join(Dir.pwd, ".kitchen.yml"))
59
- end
60
-
61
- it "prefers kitchen.yml to .kitchen.yml" do
62
- stub_file(File.join(Dir.pwd, "kitchen.yml"), {})
63
- loader = Kitchen::Loader::YAML.new
64
-
65
- loader.diagnose[:project_config][:filename]
66
- .must_equal File.expand_path(File.join(Dir.pwd, "kitchen.yml"))
67
- end
68
-
69
- it "errors when kitchen.yml and .kitchen.yml are both present" do
70
- stub_file(File.join(Dir.pwd, "kitchen.yml"), {})
71
- stub_file(File.join(Dir.pwd, ".kitchen.yml"), {})
72
- proc { Kitchen::Loader::YAML.new }.must_raise Kitchen::UserError
73
- end
74
-
75
- it "sets project_config from parameter, if given" do
76
- stub_file("/tmp/crazyfunkytown.file", {})
77
- loader = Kitchen::Loader::YAML.new(
78
- project_config: "/tmp/crazyfunkytown.file")
79
-
80
- loader.diagnose[:project_config][:filename]
81
- .must_match %r{/tmp/crazyfunkytown.file$}
82
- end
83
-
84
- it "sets local_config based on Dir.pwd by default" do
85
- stub_file(File.join(Dir.pwd, ".kitchen.local.yml"), {})
86
- loader = Kitchen::Loader::YAML.new
87
-
88
- loader.diagnose[:local_config][:filename]
89
- .must_equal File.expand_path(File.join(Dir.pwd, ".kitchen.local.yml"))
90
- end
91
-
92
- it "sets local_config based on location of project_config by default" do
93
- stub_file("/tmp/.kitchen.local.yml", {})
94
- loader = Kitchen::Loader::YAML.new(
95
- project_config: "/tmp/.kitchen.yml")
96
-
97
- loader.diagnose[:local_config][:filename]
98
- .must_match %r{/tmp/.kitchen.local.yml$}
99
- end
100
-
101
- it "errors if both visible and hidden copies of default local_config exist" do
102
- stub_file("/tmp/kitchen.local.yml", {})
103
- stub_file("/tmp/.kitchen.local.yml", {})
104
- proc { Kitchen::Loader::YAML.new(project_config: "/tmp/.kitchen.yml") }
105
- .must_raise Kitchen::UserError
106
- end
107
-
108
- it "sets local_config from parameter, if given" do
109
- stub_file("/tmp/crazyfunkytown.file", {})
110
- loader = Kitchen::Loader::YAML.new(
111
- local_config: "/tmp/crazyfunkytown.file")
112
-
113
- loader.diagnose[:local_config][:filename]
114
- .must_match %r{/tmp/crazyfunkytown.file$}
115
- end
116
-
117
- it "sets global_config based on ENV['HOME'] by default" do
118
- stub_file(File.join(ENV["HOME"], ".kitchen/config.yml"), {})
119
- loader = Kitchen::Loader::YAML.new
120
-
121
- loader.diagnose[:global_config][:filename].must_equal File.expand_path(
122
- File.join(ENV["HOME"], ".kitchen/config.yml"))
123
- end
124
-
125
- it "sets global_config from parameter, if given" do
126
- stub_file("/tmp/crazyfunkytown.file", {})
127
- loader = Kitchen::Loader::YAML.new(
128
- global_config: "/tmp/crazyfunkytown.file")
129
-
130
- loader.diagnose[:global_config][:filename]
131
- .must_match %r{/tmp/crazyfunkytown.file$}
132
- end
133
- end
134
-
135
- describe "#read" do
136
- it "returns a hash of kitchen.yml with symbolized keys" do
137
- stub_yaml!(
138
- "foo" => "bar"
139
- )
140
-
141
- loader.read.must_equal(foo: "bar")
142
- end
143
-
144
- it "deep merges in kitchen.local.yml configuration with kitchen.yml" do
145
- stub_yaml!("common" => { "xx" => 1 },
146
- "a" => "b"
147
- )
148
- stub_yaml!(
149
- {
150
- "common" => { "yy" => 2 },
151
- "c" => "d",
152
- },
153
- ".kitchen.local.yml"
154
- )
155
-
156
- loader.read.must_equal(
157
- a: "b",
158
- c: "d",
159
- common: { xx: 1, yy: 2 }
160
- )
161
- end
162
-
163
- it "deep merges in a global config file with all other configs" do
164
- stub_yaml!("common" => { "xx" => 1 },
165
- "a" => "b"
166
- )
167
- stub_yaml!(
168
- {
169
- "common" => { "yy" => 2 },
170
- "c" => "d",
171
- },
172
- ".kitchen.local.yml"
173
- )
174
- stub_global!(
175
- "common" => { "zz" => 3 },
176
- "e" => "f"
177
- )
178
-
179
- loader.read.must_equal(
180
- a: "b",
181
- c: "d",
182
- e: "f",
183
- common: { xx: 1, yy: 2, zz: 3 }
184
- )
185
- end
186
-
187
- it "merges kitchen.yml over configuration in global config" do
188
- stub_global!(
189
- "common" => { "thekey" => "nope" }
190
- )
191
- stub_yaml!("common" => { "thekey" => "yep" })
192
-
193
- loader.read.must_equal(common: { thekey: "yep" })
194
- end
195
-
196
- it "merges kitchen.local.yml over configuration in kitchen.yml" do
197
- stub_yaml!("common" => { "thekey" => "nope" })
198
- stub_yaml!(
199
- { "common" => { "thekey" => "yep" } },
200
- ".kitchen.local.yml"
201
- )
202
-
203
- loader.read.must_equal(common: { thekey: "yep" })
204
- end
205
-
206
- it "merges kitchen.local.yml over both kitchen.yml and global config" do
207
- stub_yaml!("common" => { "thekey" => "nope" })
208
- stub_yaml!(
209
- { "common" => { "thekey" => "yep" } },
210
- ".kitchen.local.yml"
211
- )
212
- stub_global!(
213
- "common" => { "thekey" => "kinda" }
214
- )
215
-
216
- loader.read.must_equal(common: { thekey: "yep" })
217
- end
218
-
219
- NORMALIZED_KEYS = {
220
- "driver" => "name",
221
- "provisioner" => "name",
222
- "busser" => "version",
223
- }.freeze
224
-
225
- NORMALIZED_KEYS.each do |key, default_key|
226
- describe "normalizing #{key} config hashes" do
227
- it "merges local with #{key} string value over yaml with hash value" do
228
- stub_yaml!(key => { "dakey" => "ya" })
229
- stub_yaml!(
230
- { key => "namey" },
231
- ".kitchen.local.yml"
232
- )
233
-
234
- loader.read.must_equal(
235
- key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
236
- )
237
- end
238
-
239
- it "merges local with #{key} hash value over yaml with string value" do
240
- stub_yaml!(key => "namey")
241
- stub_yaml!(
242
- { key => { "dakey" => "ya" } },
243
- ".kitchen.local.yml"
244
- )
245
-
246
- loader.read.must_equal(
247
- key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
248
- )
249
- end
250
-
251
- it "merges local with #{key} nil value over yaml with hash value" do
252
- stub_yaml!(key => { "dakey" => "ya" })
253
- stub_yaml!(
254
- { key => nil },
255
- ".kitchen.local.yml"
256
- )
257
-
258
- loader.read.must_equal(
259
- key.to_sym => { dakey: "ya" }
260
- )
261
- end
262
-
263
- it "merges local with #{key} hash value over yaml with nil value" do
264
- stub_yaml!(key => "namey")
265
- stub_yaml!(
266
- { key => nil },
267
- ".kitchen.local.yml"
268
- )
269
-
270
- loader.read.must_equal(
271
- key.to_sym => { default_key.to_sym => "namey" }
272
- )
273
- end
274
-
275
- it "merges global with #{key} string value over yaml with hash value" do
276
- stub_yaml!(key => { "dakey" => "ya" })
277
- stub_global!(
278
- key => "namey"
279
- )
280
-
281
- loader.read.must_equal(
282
- key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
283
- )
284
- end
285
-
286
- it "merges global with #{key} hash value over yaml with string value" do
287
- stub_yaml!(key => "namey")
288
- stub_global!(
289
- key => { "dakey" => "ya" }
290
- )
291
-
292
- loader.read.must_equal(
293
- key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
294
- )
295
- end
296
-
297
- it "merges global with #{key} nil value over yaml with hash value" do
298
- stub_yaml!(key => { "dakey" => "ya" })
299
- stub_global!(
300
- key => nil
301
- )
302
-
303
- loader.read.must_equal(
304
- key.to_sym => { dakey: "ya" }
305
- )
306
- end
307
-
308
- it "merges global with #{key} hash value over yaml with nil value" do
309
- stub_yaml!(key => nil)
310
- stub_global!(
311
- key => { "dakey" => "ya" }
312
- )
313
-
314
- loader.read.must_equal(
315
- key.to_sym => { dakey: "ya" }
316
- )
317
- end
318
-
319
- it "merges global, local, over yaml with mixed hash, string, nil values" do
320
- stub_yaml!(key => nil)
321
- stub_yaml!(
322
- { key => "namey" },
323
- ".kitchen.local.yml"
324
- )
325
- stub_global!(
326
- key => { "dakey" => "ya" }
327
- )
328
-
329
- loader.read.must_equal(
330
- key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
331
- )
332
- end
333
- end
334
- end
335
-
336
- it "handles a kitchen.local.yml with no yaml elements" do
337
- stub_yaml!("a" => "b")
338
- stub_yaml!({}, ".kitchen.local.yml")
339
-
340
- loader.read.must_equal(a: "b")
341
- end
342
-
343
- it "handles a kitchen.yml with no yaml elements" do
344
- stub_yaml!({})
345
- stub_yaml!(
346
- { "a" => "b" },
347
- ".kitchen.local.yml"
348
- )
349
-
350
- loader.read.must_equal(a: "b")
351
- end
352
-
353
- it "handles a kitchen.yml with yaml elements that parse as nil" do
354
- stub_yaml!(nil)
355
- stub_yaml!(
356
- { "a" => "b" },
357
- ".kitchen.local.yml"
358
- )
359
-
360
- loader.read.must_equal(a: "b")
361
- end
362
-
363
- it "raises an UserError if the config_file does not exist" do
364
- proc { loader.read }.must_raise Kitchen::UserError
365
- end
366
-
367
- it "arbitrary objects aren't deserialized in kitchen.yml" do
368
- FileUtils.mkdir_p "/tmp"
369
- File.open("/tmp/.kitchen.yml", "wb") do |f|
370
- f.write <<-YAML.gsub(/^ {10}/, "")
371
- --- !ruby/object:Yamled
372
- foo: bar
373
- YAML
374
- end
375
-
376
- proc { loader.read }.must_raise Kitchen::UserError
377
- end
378
-
379
- it "arbitrary objects aren't deserialized in kitchen.local.yml" do
380
- FileUtils.mkdir_p "/tmp"
381
- File.open("/tmp/.kitchen.local.yml", "wb") do |f|
382
- f.write <<-YAML.gsub(/^ {10}/, "")
383
- --- !ruby/object:Yamled
384
- wakka: boop
385
- YAML
386
- end
387
- stub_yaml!({})
388
-
389
- proc { loader.read }.must_raise Kitchen::UserError
390
- end
391
-
392
- it "raises a UserError if kitchen.yml cannot be parsed" do
393
- FileUtils.mkdir_p "/tmp"
394
- File.open("/tmp/.kitchen.yml", "wb") { |f| f.write "&*%^*" }
395
-
396
- err = proc { loader.read }.must_raise Kitchen::UserError
397
- err.message.must_match Regexp.new(
398
- "Error parsing ([a-zA-Z]:)?/tmp/.kitchen.yml")
399
- end
400
-
401
- it "raises a UserError if kitchen.yml cannot be parsed" do
402
- FileUtils.mkdir_p "/tmp"
403
- File.open("/tmp/.kitchen.yml", "wb") { |f| f.write "uhoh" }
404
-
405
- err = proc { loader.read }.must_raise Kitchen::UserError
406
- err.message.must_match Regexp.new(
407
- "Error parsing ([a-zA-Z]:)?/tmp/.kitchen.yml")
408
- end
409
-
410
- it "handles a kitchen.yml if it is a commented out YAML document" do
411
- FileUtils.mkdir_p "/tmp"
412
- File.open("/tmp/.kitchen.yml", "wb") { |f| f.write '#---\n' }
413
-
414
- loader.read.must_equal({})
415
- end
416
-
417
- it "raises a UserError if kitchen.local.yml cannot be parsed" do
418
- FileUtils.mkdir_p "/tmp"
419
- File.open("/tmp/.kitchen.local.yml", "wb") { |f| f.write "&*%^*" }
420
- stub_yaml!({})
421
-
422
- proc { loader.read }.must_raise Kitchen::UserError
423
- end
424
-
425
- it "evaluates kitchen.yml through erb before loading by default" do
426
- FileUtils.mkdir_p "/tmp"
427
- File.open("/tmp/.kitchen.yml", "wb") do |f|
428
- f.write <<-'YAML'.gsub(/^ {10}/, "")
429
- ---
430
- name: <%= "AHH".downcase + "choo" %>
431
- YAML
432
- end
433
-
434
- loader.read.must_equal(name: "ahhchoo")
435
- end
436
-
437
- it "accepts kitchen.yml with alias" do
438
- FileUtils.mkdir_p "/tmp"
439
- File.open("/tmp/.kitchen.yml", "wb") do |f|
440
- f.write <<-'YAML'.gsub(/^ {10}/, "")
441
- ---
442
- xxx: &k
443
- foo: bar
444
- yyy: *k
445
- YAML
446
- end
447
-
448
- loader.read[:yyy].must_equal(foo: "bar")
449
- end
450
-
451
- it "raises a UserError if there is an ERB processing error" do
452
- FileUtils.mkdir_p "/tmp"
453
- File.open("/tmp/.kitchen.yml", "wb") do |f|
454
- f.write <<-'YAML'.gsub(/^ {10}/, "")
455
- ---
456
- <%= poop %>: yep
457
- YAML
458
- end
459
-
460
- err = proc { loader.read }.must_raise Kitchen::UserError
461
- err.message.must_match Regexp.new(
462
- "Error parsing ERB content in ([a-zA-Z]:)?/tmp/.kitchen.yml")
463
- end
464
-
465
- it "evaluates kitchen.local.yml through erb before loading by default" do
466
- FileUtils.mkdir_p "/tmp"
467
- File.open("/tmp/.kitchen.local.yml", "wb") do |f|
468
- f.write <<-'YAML'.gsub(/^ {10}/, "")
469
- ---
470
- <% %w{noodle mushroom}.each do |kind| %>
471
- <%= kind %>: soup
472
- <% end %>
473
- YAML
474
- end
475
- stub_yaml!("spinach" => "salad")
476
-
477
- loader.read.must_equal(
478
- spinach: "salad",
479
- noodle: "soup",
480
- mushroom: "soup"
481
- )
482
- end
483
-
484
- it "skips evaluating kitchen.yml through erb if disabled" do
485
- loader = Kitchen::Loader::YAML.new(
486
- project_config: "/tmp/.kitchen.yml", process_erb: false)
487
- FileUtils.mkdir_p "/tmp"
488
- File.open("/tmp/.kitchen.yml", "wb") do |f|
489
- f.write <<-'YAML'.gsub(/^ {10}/, "")
490
- ---
491
- name: <%= "AHH".downcase %>
492
- YAML
493
- end
494
-
495
- loader.read.must_equal(name: '<%= "AHH".downcase %>')
496
- end
497
-
498
- it "skips evaluating kitchen.local.yml through erb if disabled" do
499
- loader = Kitchen::Loader::YAML.new(
500
- project_config: "/tmp/.kitchen.yml", process_erb: false)
501
- FileUtils.mkdir_p "/tmp"
502
- File.open("/tmp/.kitchen.local.yml", "wb") do |f|
503
- f.write <<-'YAML'.gsub(/^ {10}/, "")
504
- ---
505
- name: <%= "AHH".downcase %>
506
- YAML
507
- end
508
- stub_yaml!({})
509
-
510
- loader.read.must_equal(name: '<%= "AHH".downcase %>')
511
- end
512
-
513
- it "skips kitchen.local.yml if disabled" do
514
- loader = Kitchen::Loader::YAML.new(
515
- project_config: "/tmp/.kitchen.yml", process_local: false)
516
- stub_yaml!("a" => "b")
517
- stub_yaml!(
518
- { "superawesomesauceadditions" => "enabled, yo" },
519
- ".kitchen.local.yml"
520
- )
521
-
522
- loader.read.must_equal(a: "b")
523
- end
524
-
525
- it "skips the global config if disabled" do
526
- loader = Kitchen::Loader::YAML.new(
527
- project_config: "/tmp/.kitchen.yml", process_global: false)
528
- stub_yaml!("a" => "b")
529
- stub_global!(
530
- "superawesomesauceadditions" => "enabled, yo"
531
- )
532
-
533
- loader.read.must_equal(a: "b")
534
- end
535
- end
536
-
537
- describe "#diagnose" do
538
- it "returns a Hash" do
539
- stub_yaml!({})
540
-
541
- loader.diagnose.must_be_kind_of(Hash)
542
- end
543
-
544
- it "contains erb processing information when true" do
545
- stub_yaml!({})
546
-
547
- loader.diagnose[:process_erb].must_equal true
548
- end
549
-
550
- it "contains erb processing information when false" do
551
- stub_yaml!({})
552
- loader = Kitchen::Loader::YAML.new(
553
- project_config: "/tmp/.kitchen.yml", process_erb: false)
554
-
555
- loader.diagnose[:process_erb].must_equal false
556
- end
557
-
558
- it "contains local processing information when true" do
559
- stub_yaml!({})
560
-
561
- loader.diagnose[:process_local].must_equal true
562
- end
563
-
564
- it "contains local processing information when false" do
565
- stub_yaml!({})
566
- loader = Kitchen::Loader::YAML.new(
567
- project_config: "/tmp/.kitchen.yml", process_local: false)
568
-
569
- loader.diagnose[:process_local].must_equal false
570
- end
571
-
572
- it "contains global processing information when true" do
573
- stub_yaml!({})
574
-
575
- loader.diagnose[:process_global].must_equal true
576
- end
577
-
578
- it "contains global processing information when false" do
579
- stub_yaml!({})
580
- loader = Kitchen::Loader::YAML.new(
581
- project_config: "/tmp/.kitchen.yml", process_global: false)
582
-
583
- loader.diagnose[:process_global].must_equal false
584
- end
585
-
586
- describe "for yaml files" do
587
- before do
588
- stub_yaml!("from_project" => "project",
589
- "common" => { "p" => "pretty" }
590
- )
591
- stub_yaml!({
592
- "from_local" => "local",
593
- "common" => { "l" => "looky" },
594
- },
595
- ".kitchen.local.yml"
596
- )
597
- stub_global!(
598
- "from_global" => "global",
599
- "common" => { "g" => "goody" }
600
- )
601
- end
602
-
603
- it "global config contains a filename" do
604
- loader.diagnose[:global_config][:filename]
605
- .must_equal File.join(ENV["HOME"].tr('\\', "/"), ".kitchen/config.yml")
606
- end
607
-
608
- it "global config contains raw data" do
609
- loader.diagnose[:global_config][:raw_data].must_equal(
610
- "from_global" => "global",
611
- "common" => { "g" => "goody" }
612
- )
613
- end
614
-
615
- it "project config contains a filename" do
616
- loader.diagnose[:project_config][:filename]
617
- .must_match %r{/tmp/.kitchen.yml$}
618
- end
619
-
620
- it "project config contains raw data" do
621
- loader.diagnose[:project_config][:raw_data].must_equal(
622
- "from_project" => "project",
623
- "common" => { "p" => "pretty" }
624
- )
625
- end
626
-
627
- it "local config contains a filename" do
628
- loader.diagnose[:local_config][:filename]
629
- .must_match %r{/tmp/.kitchen.local.yml$}
630
- end
631
-
632
- it "local config contains raw data" do
633
- loader.diagnose[:local_config][:raw_data].must_equal(
634
- "from_local" => "local",
635
- "common" => { "l" => "looky" }
636
- )
637
- end
638
-
639
- it "combined config contains a nil filename" do
640
- loader.diagnose[:combined_config][:filename]
641
- .must_be_nil
642
- end
643
-
644
- it "combined config contains raw data" do
645
- loader.diagnose[:combined_config][:raw_data].must_equal(
646
- "from_global" => "global",
647
- "from_project" => "project",
648
- "from_local" => "local",
649
- "common" => {
650
- "g" => "goody",
651
- "p" => "pretty",
652
- "l" => "looky",
653
- }
654
- )
655
- end
656
-
657
- describe "for global on error" do
658
- before do
659
- FileUtils.mkdir_p(File.join(ENV["HOME"], ".kitchen"))
660
- File.open(File.join(ENV["HOME"], ".kitchen/config.yml"), "wb") do |f|
661
- f.write "&*%^*"
662
- end
663
- end
664
-
665
- it "uses an error hash with the raw file contents" do
666
- loader.diagnose[:global_config][:raw_data][:error][:raw_file]
667
- .must_equal "&*%^*"
668
- end
669
-
670
- it "uses an error hash with the exception" do
671
- loader.diagnose[:global_config][:raw_data][:error][:exception]
672
- .must_match(/Kitchen::UserError/)
673
- end
674
-
675
- it "uses an error hash with the exception message" do
676
- loader.diagnose[:global_config][:raw_data][:error][:message]
677
- .must_match(/Error parsing/)
678
- end
679
-
680
- it "uses an error hash with the exception backtrace" do
681
- loader.diagnose[:global_config][:raw_data][:error][:backtrace]
682
- .must_be_kind_of Array
683
- end
684
- end
685
-
686
- describe "for project on error" do
687
- before do
688
- File.open("/tmp/.kitchen.yml", "wb") do |f|
689
- f.write "&*%^*"
690
- end
691
- end
692
-
693
- it "uses an error hash with the raw file contents" do
694
- loader.diagnose[:project_config][:raw_data][:error][:raw_file]
695
- .must_equal "&*%^*"
696
- end
697
-
698
- it "uses an error hash with the exception" do
699
- loader.diagnose[:project_config][:raw_data][:error][:exception]
700
- .must_match(/Kitchen::UserError/)
701
- end
702
-
703
- it "uses an error hash with the exception message" do
704
- loader.diagnose[:project_config][:raw_data][:error][:message]
705
- .must_match(/Error parsing/)
706
- end
707
-
708
- it "uses an error hash with the exception backtrace" do
709
- loader.diagnose[:project_config][:raw_data][:error][:backtrace]
710
- .must_be_kind_of Array
711
- end
712
- end
713
-
714
- describe "for local on error" do
715
- before do
716
- File.open("/tmp/.kitchen.local.yml", "wb") do |f|
717
- f.write "&*%^*"
718
- end
719
- end
720
-
721
- it "uses an error hash with the raw file contents" do
722
- loader.diagnose[:local_config][:raw_data][:error][:raw_file]
723
- .must_equal "&*%^*"
724
- end
725
-
726
- it "uses an error hash with the exception" do
727
- loader.diagnose[:local_config][:raw_data][:error][:exception]
728
- .must_match(/Kitchen::UserError/)
729
- end
730
-
731
- it "uses an error hash with the exception message" do
732
- loader.diagnose[:local_config][:raw_data][:error][:message]
733
- .must_match(/Error parsing/)
734
- end
735
-
736
- it "uses an error hash with the exception backtrace" do
737
- loader.diagnose[:local_config][:raw_data][:error][:backtrace]
738
- .must_be_kind_of Array
739
- end
740
- end
741
-
742
- describe "for combined on error" do
743
- before do
744
- File.open("/tmp/.kitchen.yml", "wb") do |f|
745
- f.write "&*%^*"
746
- end
747
- end
748
-
749
- it "uses an error hash with nil raw file contents" do
750
- loader.diagnose[:combined_config][:raw_data][:error][:raw_file]
751
- .must_be_nil
752
- end
753
-
754
- it "uses an error hash with the exception" do
755
- loader.diagnose[:combined_config][:raw_data][:error][:exception]
756
- .must_match(/Kitchen::UserError/)
757
- end
758
-
759
- it "uses an error hash with the exception message" do
760
- loader.diagnose[:combined_config][:raw_data][:error][:message]
761
- .must_match(/Error parsing/)
762
- end
763
-
764
- it "uses an error hash with the exception backtrace" do
765
- loader.diagnose[:combined_config][:raw_data][:error][:backtrace]
766
- .must_be_kind_of Array
767
- end
768
- end
769
- end
770
- end
771
-
772
- private
773
-
774
- def stub_file(path, hash)
775
- FileUtils.mkdir_p(File.dirname(path))
776
- File.open(path, "wb") { |f| f.write(hash.to_yaml) }
777
- end
778
-
779
- def stub_yaml!(hash, name = ".kitchen.yml")
780
- stub_file(File.join("/tmp", name), hash)
781
- end
782
-
783
- def stub_global!(hash)
784
- stub_file(File.join(File.expand_path(ENV["HOME"]),
785
- ".kitchen", "config.yml"), hash)
786
- end
787
- end