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.
- checksums.yaml +4 -4
- data/Berksfile +1 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/Guardfile +5 -5
- data/Rakefile +5 -5
- data/bin/kitchen +1 -1
- data/features/step_definitions/gem_steps.rb +6 -6
- data/features/support/env.rb +6 -7
- data/lib/kitchen.rb +5 -7
- data/lib/kitchen/base64_stream.rb +2 -8
- data/lib/kitchen/cli.rb +76 -80
- data/lib/kitchen/collection.rb +0 -2
- data/lib/kitchen/color.rb +7 -9
- data/lib/kitchen/command.rb +0 -4
- data/lib/kitchen/command/action.rb +0 -3
- data/lib/kitchen/command/console.rb +4 -7
- data/lib/kitchen/command/diagnose.rb +7 -14
- data/lib/kitchen/command/driver_discover.rb +1 -4
- data/lib/kitchen/command/exec.rb +0 -3
- data/lib/kitchen/command/list.rb +9 -12
- data/lib/kitchen/command/login.rb +0 -3
- data/lib/kitchen/command/package.rb +0 -3
- data/lib/kitchen/command/sink.rb +6 -9
- data/lib/kitchen/command/test.rb +1 -4
- data/lib/kitchen/config.rb +25 -27
- data/lib/kitchen/configurable.rb +26 -31
- data/lib/kitchen/data_munger.rb +34 -36
- data/lib/kitchen/diagnostic.rb +5 -7
- data/lib/kitchen/driver.rb +3 -5
- data/lib/kitchen/driver/base.rb +0 -3
- data/lib/kitchen/driver/dummy.rb +0 -3
- data/lib/kitchen/driver/proxy.rb +0 -3
- data/lib/kitchen/driver/ssh_base.rb +13 -16
- data/lib/kitchen/errors.rb +11 -16
- data/lib/kitchen/generator/driver_create.rb +18 -21
- data/lib/kitchen/generator/init.rb +21 -26
- data/lib/kitchen/instance.rb +19 -23
- data/lib/kitchen/lazy_hash.rb +1 -2
- data/lib/kitchen/loader/yaml.rb +22 -25
- data/lib/kitchen/logger.rb +9 -14
- data/lib/kitchen/logging.rb +0 -3
- data/lib/kitchen/login_command.rb +0 -2
- data/lib/kitchen/metadata_chopper.rb +0 -2
- data/lib/kitchen/platform.rb +1 -3
- data/lib/kitchen/provisioner.rb +3 -5
- data/lib/kitchen/provisioner/base.rb +2 -5
- data/lib/kitchen/provisioner/chef/berkshelf.rb +1 -5
- data/lib/kitchen/provisioner/chef/common_sandbox.rb +24 -29
- data/lib/kitchen/provisioner/chef/librarian.rb +2 -6
- data/lib/kitchen/provisioner/chef/policyfile.rb +4 -8
- data/lib/kitchen/provisioner/chef_apply.rb +14 -17
- data/lib/kitchen/provisioner/chef_base.rb +43 -46
- data/lib/kitchen/provisioner/chef_solo.rb +10 -13
- data/lib/kitchen/provisioner/chef_zero.rb +22 -29
- data/lib/kitchen/provisioner/dummy.rb +0 -3
- data/lib/kitchen/provisioner/shell.rb +6 -9
- data/lib/kitchen/rake_tasks.rb +4 -6
- data/lib/kitchen/shell_out.rb +3 -5
- data/lib/kitchen/ssh.rb +16 -22
- data/lib/kitchen/state_file.rb +3 -5
- data/lib/kitchen/suite.rb +0 -2
- data/lib/kitchen/thor_tasks.rb +2 -4
- data/lib/kitchen/transport.rb +3 -5
- data/lib/kitchen/transport/base.rb +1 -7
- data/lib/kitchen/transport/dummy.rb +0 -4
- data/lib/kitchen/transport/ssh.rb +41 -47
- data/lib/kitchen/transport/winrm.rb +41 -40
- data/lib/kitchen/util.rb +1 -3
- data/lib/kitchen/verifier.rb +3 -5
- data/lib/kitchen/verifier/base.rb +2 -5
- data/lib/kitchen/verifier/busser.rb +24 -24
- data/lib/kitchen/verifier/dummy.rb +0 -3
- data/lib/kitchen/verifier/shell.rb +1 -3
- data/lib/kitchen/version.rb +1 -1
- data/lib/vendor/hash_recursive_merge.rb +0 -2
- data/spec/kitchen/base64_stream_spec.rb +3 -6
- data/spec/kitchen/cli_spec.rb +0 -2
- data/spec/kitchen/collection_spec.rb +4 -8
- data/spec/kitchen/color_spec.rb +0 -3
- data/spec/kitchen/config_spec.rb +91 -106
- data/spec/kitchen/configurable_spec.rb +44 -76
- data/spec/kitchen/data_munger_spec.rb +1178 -1247
- data/spec/kitchen/diagnostic_spec.rb +37 -38
- data/spec/kitchen/driver/base_spec.rb +7 -14
- data/spec/kitchen/driver/dummy_spec.rb +1 -7
- data/spec/kitchen/driver/proxy_spec.rb +2 -7
- data/spec/kitchen/driver/ssh_base_spec.rb +128 -149
- data/spec/kitchen/driver_spec.rb +7 -13
- data/spec/kitchen/errors_spec.rb +50 -60
- data/spec/kitchen/instance_spec.rb +217 -294
- data/spec/kitchen/lazy_hash_spec.rb +14 -18
- data/spec/kitchen/loader/yaml_spec.rb +201 -227
- data/spec/kitchen/logger_spec.rb +7 -15
- data/spec/kitchen/logging_spec.rb +1 -4
- data/spec/kitchen/login_command_spec.rb +3 -4
- data/spec/kitchen/metadata_chopper_spec.rb +0 -3
- data/spec/kitchen/platform_spec.rb +31 -32
- data/spec/kitchen/provisioner/base_spec.rb +22 -41
- data/spec/kitchen/provisioner/chef/policyfile_spec.rb +15 -15
- data/spec/kitchen/provisioner/chef_apply_spec.rb +8 -13
- data/spec/kitchen/provisioner/chef_base_spec.rb +150 -182
- data/spec/kitchen/provisioner/chef_solo_spec.rb +58 -72
- data/spec/kitchen/provisioner/chef_zero_spec.rb +99 -125
- data/spec/kitchen/provisioner/dummy_spec.rb +8 -11
- data/spec/kitchen/provisioner/shell_spec.rb +86 -103
- data/spec/kitchen/provisioner_spec.rb +5 -11
- data/spec/kitchen/shell_out_spec.rb +15 -19
- data/spec/kitchen/ssh_spec.rb +16 -35
- data/spec/kitchen/state_file_spec.rb +6 -11
- data/spec/kitchen/suite_spec.rb +5 -6
- data/spec/kitchen/transport/base_spec.rb +6 -14
- data/spec/kitchen/transport/ssh_spec.rb +39 -64
- data/spec/kitchen/transport/winrm_spec.rb +99 -127
- data/spec/kitchen/transport_spec.rb +7 -13
- data/spec/kitchen/util_spec.rb +17 -26
- data/spec/kitchen/verifier/base_spec.rb +24 -40
- data/spec/kitchen/verifier/busser_spec.rb +38 -68
- data/spec/kitchen/verifier/dummy_spec.rb +8 -11
- data/spec/kitchen/verifier/shell_spec.rb +14 -17
- data/spec/kitchen/verifier_spec.rb +7 -13
- data/spec/kitchen_spec.rb +4 -6
- data/spec/spec_helper.rb +1 -1
- data/spec/support/powershell_max_size_spec.rb +1 -2
- data/support/chef-client-zero.rb +3 -4
- data/test-kitchen.gemspec +4 -6
- metadata +9 -9
|
@@ -21,21 +21,19 @@ require_relative "../spec_helper"
|
|
|
21
21
|
require "kitchen/lazy_hash"
|
|
22
22
|
|
|
23
23
|
describe Kitchen::LazyHash do
|
|
24
|
-
|
|
25
24
|
let(:context) do
|
|
26
|
-
stub(:
|
|
25
|
+
stub(color: "blue", metal: "heavy")
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
let(:hash_obj) do
|
|
30
29
|
{
|
|
31
|
-
:
|
|
32
|
-
:
|
|
33
|
-
:
|
|
30
|
+
shed_color: ->(c) { c.color },
|
|
31
|
+
barn: "locked",
|
|
32
|
+
genre: proc { |c| "#{c.metal} metal" },
|
|
34
33
|
}
|
|
35
34
|
end
|
|
36
35
|
|
|
37
36
|
describe "#[]" do
|
|
38
|
-
|
|
39
37
|
it "returns regular values for keys" do
|
|
40
38
|
Kitchen::LazyHash.new(hash_obj, context)[:barn].must_equal "locked"
|
|
41
39
|
end
|
|
@@ -50,34 +48,32 @@ describe Kitchen::LazyHash do
|
|
|
50
48
|
end
|
|
51
49
|
|
|
52
50
|
describe "#fetch" do
|
|
53
|
-
|
|
54
51
|
it "returns regular hash values for keys" do
|
|
55
52
|
Kitchen::LazyHash.new(hash_obj, context).fetch(:barn).must_equal "locked"
|
|
56
53
|
end
|
|
57
54
|
|
|
58
55
|
it "invokes call on values that are lambdas" do
|
|
59
|
-
Kitchen::LazyHash.new(hash_obj, context)
|
|
60
|
-
|
|
56
|
+
Kitchen::LazyHash.new(hash_obj, context)
|
|
57
|
+
.fetch(:shed_color).must_equal "blue"
|
|
61
58
|
end
|
|
62
59
|
|
|
63
60
|
it "invokes call on values that are Procs" do
|
|
64
|
-
Kitchen::LazyHash.new(hash_obj, context)
|
|
65
|
-
|
|
61
|
+
Kitchen::LazyHash.new(hash_obj, context)
|
|
62
|
+
.fetch(:genre).must_equal "heavy metal"
|
|
66
63
|
end
|
|
67
64
|
|
|
68
65
|
it "uses a default value for unset values" do
|
|
69
|
-
Kitchen::LazyHash.new(hash_obj, context)
|
|
70
|
-
|
|
66
|
+
Kitchen::LazyHash.new(hash_obj, context)
|
|
67
|
+
.fetch(:nope, "candy").must_equal "candy"
|
|
71
68
|
end
|
|
72
69
|
|
|
73
70
|
it "uses a block for unset values" do
|
|
74
|
-
Kitchen::LazyHash.new(hash_obj, context)
|
|
75
|
-
|
|
71
|
+
Kitchen::LazyHash.new(hash_obj, context)
|
|
72
|
+
.fetch(:nope) { |key| "#{key} is costly" }.must_equal "nope is costly"
|
|
76
73
|
end
|
|
77
74
|
end
|
|
78
75
|
|
|
79
76
|
describe "#to_hash" do
|
|
80
|
-
|
|
81
77
|
it "invokes any callable values and returns a Hash object" do
|
|
82
78
|
converted = Kitchen::LazyHash.new(hash_obj, context).to_hash
|
|
83
79
|
|
|
@@ -90,8 +86,8 @@ describe Kitchen::LazyHash do
|
|
|
90
86
|
|
|
91
87
|
describe "select" do
|
|
92
88
|
it "calls Procs when appropriate" do
|
|
93
|
-
Kitchen::LazyHash.new(hash_obj, context).select { |_, _| true }
|
|
94
|
-
|
|
89
|
+
Kitchen::LazyHash.new(hash_obj, context).select { |_, _| true }
|
|
90
|
+
.must_equal shed_color: "blue", barn: "locked", genre: "heavy metal"
|
|
95
91
|
end
|
|
96
92
|
end
|
|
97
93
|
|
|
@@ -27,9 +27,8 @@ class Yamled
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
describe Kitchen::Loader::YAML do
|
|
30
|
-
|
|
31
30
|
let(:loader) do
|
|
32
|
-
Kitchen::Loader::YAML.new(:
|
|
31
|
+
Kitchen::Loader::YAML.new(project_config: "/tmp/.kitchen.yml")
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
before do
|
|
@@ -43,52 +42,51 @@ describe Kitchen::Loader::YAML do
|
|
|
43
42
|
end
|
|
44
43
|
|
|
45
44
|
describe ".initialize" do
|
|
46
|
-
|
|
47
45
|
it "sets project_config based on Dir.pwd by default" do
|
|
48
|
-
stub_file(File.join(Dir.pwd, ".kitchen.yml"),
|
|
46
|
+
stub_file(File.join(Dir.pwd, ".kitchen.yml"), {})
|
|
49
47
|
loader = Kitchen::Loader::YAML.new
|
|
50
48
|
|
|
51
|
-
loader.diagnose[:project_config][:filename]
|
|
52
|
-
must_equal File.expand_path(File.join(Dir.pwd, ".kitchen.yml"))
|
|
49
|
+
loader.diagnose[:project_config][:filename]
|
|
50
|
+
.must_equal File.expand_path(File.join(Dir.pwd, ".kitchen.yml"))
|
|
53
51
|
end
|
|
54
52
|
|
|
55
53
|
it "sets project_config from parameter, if given" do
|
|
56
|
-
stub_file("/tmp/crazyfunkytown.file",
|
|
54
|
+
stub_file("/tmp/crazyfunkytown.file", {})
|
|
57
55
|
loader = Kitchen::Loader::YAML.new(
|
|
58
|
-
:
|
|
56
|
+
project_config: "/tmp/crazyfunkytown.file")
|
|
59
57
|
|
|
60
|
-
loader.diagnose[:project_config][:filename]
|
|
61
|
-
must_match %r{/tmp/crazyfunkytown.file$}
|
|
58
|
+
loader.diagnose[:project_config][:filename]
|
|
59
|
+
.must_match %r{/tmp/crazyfunkytown.file$}
|
|
62
60
|
end
|
|
63
61
|
|
|
64
62
|
it "sets local_config based on Dir.pwd by default" do
|
|
65
|
-
stub_file(File.join(Dir.pwd, ".kitchen.local.yml"),
|
|
63
|
+
stub_file(File.join(Dir.pwd, ".kitchen.local.yml"), {})
|
|
66
64
|
loader = Kitchen::Loader::YAML.new
|
|
67
65
|
|
|
68
|
-
loader.diagnose[:local_config][:filename]
|
|
69
|
-
must_equal File.expand_path(File.join(Dir.pwd, ".kitchen.local.yml"))
|
|
66
|
+
loader.diagnose[:local_config][:filename]
|
|
67
|
+
.must_equal File.expand_path(File.join(Dir.pwd, ".kitchen.local.yml"))
|
|
70
68
|
end
|
|
71
69
|
|
|
72
70
|
it "sets local_config based on location of project_config by default" do
|
|
73
|
-
stub_file("/tmp/.kitchen.local.yml",
|
|
71
|
+
stub_file("/tmp/.kitchen.local.yml", {})
|
|
74
72
|
loader = Kitchen::Loader::YAML.new(
|
|
75
|
-
:
|
|
73
|
+
project_config: "/tmp/.kitchen.yml")
|
|
76
74
|
|
|
77
|
-
loader.diagnose[:local_config][:filename]
|
|
78
|
-
must_match %r{/tmp/.kitchen.local.yml$}
|
|
75
|
+
loader.diagnose[:local_config][:filename]
|
|
76
|
+
.must_match %r{/tmp/.kitchen.local.yml$}
|
|
79
77
|
end
|
|
80
78
|
|
|
81
79
|
it "sets local_config from parameter, if given" do
|
|
82
|
-
stub_file("/tmp/crazyfunkytown.file",
|
|
80
|
+
stub_file("/tmp/crazyfunkytown.file", {})
|
|
83
81
|
loader = Kitchen::Loader::YAML.new(
|
|
84
|
-
:
|
|
82
|
+
local_config: "/tmp/crazyfunkytown.file")
|
|
85
83
|
|
|
86
|
-
loader.diagnose[:local_config][:filename]
|
|
87
|
-
must_match %r{/tmp/crazyfunkytown.file$}
|
|
84
|
+
loader.diagnose[:local_config][:filename]
|
|
85
|
+
.must_match %r{/tmp/crazyfunkytown.file$}
|
|
88
86
|
end
|
|
89
87
|
|
|
90
88
|
it "sets global_config based on ENV['HOME'] by default" do
|
|
91
|
-
stub_file(File.join(ENV["HOME"], ".kitchen/config.yml"),
|
|
89
|
+
stub_file(File.join(ENV["HOME"], ".kitchen/config.yml"), {})
|
|
92
90
|
loader = Kitchen::Loader::YAML.new
|
|
93
91
|
|
|
94
92
|
loader.diagnose[:global_config][:filename].must_equal File.expand_path(
|
|
@@ -96,61 +94,64 @@ describe Kitchen::Loader::YAML do
|
|
|
96
94
|
end
|
|
97
95
|
|
|
98
96
|
it "sets global_config from parameter, if given" do
|
|
99
|
-
stub_file("/tmp/crazyfunkytown.file",
|
|
97
|
+
stub_file("/tmp/crazyfunkytown.file", {})
|
|
100
98
|
loader = Kitchen::Loader::YAML.new(
|
|
101
|
-
:
|
|
99
|
+
global_config: "/tmp/crazyfunkytown.file")
|
|
102
100
|
|
|
103
|
-
loader.diagnose[:global_config][:filename]
|
|
104
|
-
must_match %r{/tmp/crazyfunkytown.file$}
|
|
101
|
+
loader.diagnose[:global_config][:filename]
|
|
102
|
+
.must_match %r{/tmp/crazyfunkytown.file$}
|
|
105
103
|
end
|
|
106
104
|
end
|
|
107
105
|
|
|
108
106
|
describe "#read" do
|
|
109
|
-
|
|
110
107
|
it "returns a hash of kitchen.yml with symbolized keys" do
|
|
111
108
|
stub_yaml!(
|
|
112
109
|
"foo" => "bar"
|
|
113
110
|
)
|
|
114
111
|
|
|
115
|
-
loader.read.must_equal(:
|
|
112
|
+
loader.read.must_equal(foo: "bar")
|
|
116
113
|
end
|
|
117
114
|
|
|
118
115
|
it "deep merges in kitchen.local.yml configuration with kitchen.yml" do
|
|
119
|
-
stub_yaml!("
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
116
|
+
stub_yaml!("common" => { "xx" => 1 },
|
|
117
|
+
"a" => "b"
|
|
118
|
+
)
|
|
119
|
+
stub_yaml!(
|
|
120
|
+
{
|
|
121
|
+
"common" => { "yy" => 2 },
|
|
122
|
+
"c" => "d",
|
|
123
|
+
},
|
|
124
|
+
".kitchen.local.yml"
|
|
125
|
+
)
|
|
127
126
|
|
|
128
127
|
loader.read.must_equal(
|
|
129
|
-
:
|
|
130
|
-
:
|
|
131
|
-
:
|
|
128
|
+
a: "b",
|
|
129
|
+
c: "d",
|
|
130
|
+
common: { xx: 1, yy: 2 }
|
|
132
131
|
)
|
|
133
132
|
end
|
|
134
133
|
|
|
135
134
|
it "deep merges in a global config file with all other configs" do
|
|
136
|
-
stub_yaml!("
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
stub_yaml!("common" => { "xx" => 1 },
|
|
136
|
+
"a" => "b"
|
|
137
|
+
)
|
|
138
|
+
stub_yaml!(
|
|
139
|
+
{
|
|
140
|
+
"common" => { "yy" => 2 },
|
|
141
|
+
"c" => "d",
|
|
142
|
+
},
|
|
143
|
+
".kitchen.local.yml"
|
|
144
|
+
)
|
|
144
145
|
stub_global!(
|
|
145
146
|
"common" => { "zz" => 3 },
|
|
146
147
|
"e" => "f"
|
|
147
148
|
)
|
|
148
149
|
|
|
149
150
|
loader.read.must_equal(
|
|
150
|
-
:
|
|
151
|
-
:
|
|
152
|
-
:
|
|
153
|
-
:
|
|
151
|
+
a: "b",
|
|
152
|
+
c: "d",
|
|
153
|
+
e: "f",
|
|
154
|
+
common: { xx: 1, yy: 2, zz: 3 }
|
|
154
155
|
)
|
|
155
156
|
end
|
|
156
157
|
|
|
@@ -158,55 +159,48 @@ describe Kitchen::Loader::YAML do
|
|
|
158
159
|
stub_global!(
|
|
159
160
|
"common" => { "thekey" => "nope" }
|
|
160
161
|
)
|
|
161
|
-
stub_yaml!("
|
|
162
|
-
"common" => { "thekey" => "yep" }
|
|
163
|
-
)
|
|
162
|
+
stub_yaml!("common" => { "thekey" => "yep" })
|
|
164
163
|
|
|
165
|
-
loader.read.must_equal(:
|
|
164
|
+
loader.read.must_equal(common: { thekey: "yep" })
|
|
166
165
|
end
|
|
167
166
|
|
|
168
167
|
it "merges kitchen.local.yml over configuration in kitchen.yml" do
|
|
169
|
-
stub_yaml!("
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
)
|
|
168
|
+
stub_yaml!("common" => { "thekey" => "nope" })
|
|
169
|
+
stub_yaml!(
|
|
170
|
+
{ "common" => { "thekey" => "yep" } },
|
|
171
|
+
".kitchen.local.yml"
|
|
172
|
+
)
|
|
175
173
|
|
|
176
|
-
loader.read.must_equal(:
|
|
174
|
+
loader.read.must_equal(common: { thekey: "yep" })
|
|
177
175
|
end
|
|
178
176
|
|
|
179
177
|
it "merges kitchen.local.yml over both kitchen.yml and global config" do
|
|
180
|
-
stub_yaml!("
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
)
|
|
178
|
+
stub_yaml!("common" => { "thekey" => "nope" })
|
|
179
|
+
stub_yaml!(
|
|
180
|
+
{ "common" => { "thekey" => "yep" } },
|
|
181
|
+
".kitchen.local.yml"
|
|
182
|
+
)
|
|
186
183
|
stub_global!(
|
|
187
184
|
"common" => { "thekey" => "kinda" }
|
|
188
185
|
)
|
|
189
186
|
|
|
190
|
-
loader.read.must_equal(:
|
|
187
|
+
loader.read.must_equal(common: { thekey: "yep" })
|
|
191
188
|
end
|
|
192
189
|
|
|
193
190
|
NORMALIZED_KEYS = {
|
|
194
191
|
"driver" => "name",
|
|
195
192
|
"provisioner" => "name",
|
|
196
|
-
"busser" => "version"
|
|
197
|
-
}
|
|
193
|
+
"busser" => "version",
|
|
194
|
+
}.freeze
|
|
198
195
|
|
|
199
196
|
NORMALIZED_KEYS.each do |key, default_key|
|
|
200
|
-
|
|
201
197
|
describe "normalizing #{key} config hashes" do
|
|
202
|
-
|
|
203
198
|
it "merges local with #{key} string value over yaml with hash value" do
|
|
204
|
-
stub_yaml!("
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
)
|
|
199
|
+
stub_yaml!(key => { "dakey" => "ya" })
|
|
200
|
+
stub_yaml!(
|
|
201
|
+
{ key => "namey" },
|
|
202
|
+
".kitchen.local.yml"
|
|
203
|
+
)
|
|
210
204
|
|
|
211
205
|
loader.read.must_equal(
|
|
212
206
|
key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
|
|
@@ -214,12 +208,11 @@ describe Kitchen::Loader::YAML do
|
|
|
214
208
|
end
|
|
215
209
|
|
|
216
210
|
it "merges local with #{key} hash value over yaml with string value" do
|
|
217
|
-
stub_yaml!("
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
)
|
|
211
|
+
stub_yaml!(key => "namey")
|
|
212
|
+
stub_yaml!(
|
|
213
|
+
{ key => { "dakey" => "ya" } },
|
|
214
|
+
".kitchen.local.yml"
|
|
215
|
+
)
|
|
223
216
|
|
|
224
217
|
loader.read.must_equal(
|
|
225
218
|
key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
|
|
@@ -227,25 +220,23 @@ describe Kitchen::Loader::YAML do
|
|
|
227
220
|
end
|
|
228
221
|
|
|
229
222
|
it "merges local with #{key} nil value over yaml with hash value" do
|
|
230
|
-
stub_yaml!("
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
)
|
|
223
|
+
stub_yaml!(key => { "dakey" => "ya" })
|
|
224
|
+
stub_yaml!(
|
|
225
|
+
{ key => nil },
|
|
226
|
+
".kitchen.local.yml"
|
|
227
|
+
)
|
|
236
228
|
|
|
237
229
|
loader.read.must_equal(
|
|
238
|
-
key.to_sym => { :
|
|
230
|
+
key.to_sym => { dakey: "ya" }
|
|
239
231
|
)
|
|
240
232
|
end
|
|
241
233
|
|
|
242
234
|
it "merges local with #{key} hash value over yaml with nil value" do
|
|
243
|
-
stub_yaml!("
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
)
|
|
235
|
+
stub_yaml!(key => "namey")
|
|
236
|
+
stub_yaml!(
|
|
237
|
+
{ key => nil },
|
|
238
|
+
".kitchen.local.yml"
|
|
239
|
+
)
|
|
249
240
|
|
|
250
241
|
loader.read.must_equal(
|
|
251
242
|
key.to_sym => { default_key.to_sym => "namey" }
|
|
@@ -253,9 +244,7 @@ describe Kitchen::Loader::YAML do
|
|
|
253
244
|
end
|
|
254
245
|
|
|
255
246
|
it "merges global with #{key} string value over yaml with hash value" do
|
|
256
|
-
stub_yaml!("
|
|
257
|
-
key => { "dakey" => "ya" }
|
|
258
|
-
)
|
|
247
|
+
stub_yaml!(key => { "dakey" => "ya" })
|
|
259
248
|
stub_global!(
|
|
260
249
|
key => "namey"
|
|
261
250
|
)
|
|
@@ -266,9 +255,7 @@ describe Kitchen::Loader::YAML do
|
|
|
266
255
|
end
|
|
267
256
|
|
|
268
257
|
it "merges global with #{key} hash value over yaml with string value" do
|
|
269
|
-
stub_yaml!("
|
|
270
|
-
key => "namey"
|
|
271
|
-
)
|
|
258
|
+
stub_yaml!(key => "namey")
|
|
272
259
|
stub_global!(
|
|
273
260
|
key => { "dakey" => "ya" }
|
|
274
261
|
)
|
|
@@ -279,38 +266,33 @@ describe Kitchen::Loader::YAML do
|
|
|
279
266
|
end
|
|
280
267
|
|
|
281
268
|
it "merges global with #{key} nil value over yaml with hash value" do
|
|
282
|
-
stub_yaml!("
|
|
283
|
-
key => { "dakey" => "ya" }
|
|
284
|
-
)
|
|
269
|
+
stub_yaml!(key => { "dakey" => "ya" })
|
|
285
270
|
stub_global!(
|
|
286
271
|
key => nil
|
|
287
272
|
)
|
|
288
273
|
|
|
289
274
|
loader.read.must_equal(
|
|
290
|
-
key.to_sym => { :
|
|
275
|
+
key.to_sym => { dakey: "ya" }
|
|
291
276
|
)
|
|
292
277
|
end
|
|
293
278
|
|
|
294
279
|
it "merges global with #{key} hash value over yaml with nil value" do
|
|
295
|
-
stub_yaml!(
|
|
296
|
-
key => nil
|
|
297
|
-
)
|
|
280
|
+
stub_yaml!(key => nil)
|
|
298
281
|
stub_global!(
|
|
299
282
|
key => { "dakey" => "ya" }
|
|
300
283
|
)
|
|
301
284
|
|
|
302
285
|
loader.read.must_equal(
|
|
303
|
-
key.to_sym => { :
|
|
286
|
+
key.to_sym => { dakey: "ya" }
|
|
304
287
|
)
|
|
305
288
|
end
|
|
306
289
|
|
|
307
290
|
it "merges global, local, over yaml with mixed hash, string, nil values" do
|
|
308
|
-
stub_yaml!(
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
)
|
|
291
|
+
stub_yaml!(key => nil)
|
|
292
|
+
stub_yaml!(
|
|
293
|
+
{ key => "namey" },
|
|
294
|
+
".kitchen.local.yml"
|
|
295
|
+
)
|
|
314
296
|
stub_global!(
|
|
315
297
|
key => { "dakey" => "ya" }
|
|
316
298
|
)
|
|
@@ -323,30 +305,30 @@ describe Kitchen::Loader::YAML do
|
|
|
323
305
|
end
|
|
324
306
|
|
|
325
307
|
it "handles a kitchen.local.yml with no yaml elements" do
|
|
326
|
-
stub_yaml!("
|
|
327
|
-
|
|
328
|
-
)
|
|
329
|
-
stub_yaml!(".kitchen.local.yml", Hash.new)
|
|
308
|
+
stub_yaml!("a" => "b")
|
|
309
|
+
stub_yaml!({}, ".kitchen.local.yml")
|
|
330
310
|
|
|
331
|
-
loader.read.must_equal(:
|
|
311
|
+
loader.read.must_equal(a: "b")
|
|
332
312
|
end
|
|
333
313
|
|
|
334
314
|
it "handles a kitchen.yml with no yaml elements" do
|
|
335
|
-
stub_yaml!(
|
|
336
|
-
stub_yaml!(
|
|
337
|
-
"a" => "b"
|
|
315
|
+
stub_yaml!({})
|
|
316
|
+
stub_yaml!(
|
|
317
|
+
{ "a" => "b" },
|
|
318
|
+
".kitchen.local.yml"
|
|
338
319
|
)
|
|
339
320
|
|
|
340
|
-
loader.read.must_equal(:
|
|
321
|
+
loader.read.must_equal(a: "b")
|
|
341
322
|
end
|
|
342
323
|
|
|
343
324
|
it "handles a kitchen.yml with yaml elements that parse as nil" do
|
|
344
|
-
stub_yaml!(
|
|
345
|
-
stub_yaml!(
|
|
346
|
-
"a" => "b"
|
|
325
|
+
stub_yaml!(nil)
|
|
326
|
+
stub_yaml!(
|
|
327
|
+
{ "a" => "b" },
|
|
328
|
+
".kitchen.local.yml"
|
|
347
329
|
)
|
|
348
330
|
|
|
349
|
-
loader.read.must_equal(:
|
|
331
|
+
loader.read.must_equal(a: "b")
|
|
350
332
|
end
|
|
351
333
|
|
|
352
334
|
it "raises an UserError if the config_file does not exist" do
|
|
@@ -364,7 +346,7 @@ describe Kitchen::Loader::YAML do
|
|
|
364
346
|
|
|
365
347
|
loader.read.class.wont_equal Yamled
|
|
366
348
|
loader.read.class.must_equal Hash
|
|
367
|
-
loader.read.must_equal(:
|
|
349
|
+
loader.read.must_equal(foo: "bar")
|
|
368
350
|
end
|
|
369
351
|
|
|
370
352
|
it "arbitrary objects aren't deserialized in kitchen.local.yml" do
|
|
@@ -375,11 +357,11 @@ describe Kitchen::Loader::YAML do
|
|
|
375
357
|
wakka: boop
|
|
376
358
|
YAML
|
|
377
359
|
end
|
|
378
|
-
stub_yaml!(
|
|
360
|
+
stub_yaml!({})
|
|
379
361
|
|
|
380
362
|
loader.read.class.wont_equal Yamled
|
|
381
363
|
loader.read.class.must_equal Hash
|
|
382
|
-
loader.read.must_equal(:
|
|
364
|
+
loader.read.must_equal(wakka: "boop")
|
|
383
365
|
end
|
|
384
366
|
|
|
385
367
|
it "raises a UserError if kitchen.yml cannot be parsed" do
|
|
@@ -388,7 +370,7 @@ describe Kitchen::Loader::YAML do
|
|
|
388
370
|
|
|
389
371
|
err = proc { loader.read }.must_raise Kitchen::UserError
|
|
390
372
|
err.message.must_match Regexp.new(
|
|
391
|
-
"Error parsing ([a-zA-Z]:)
|
|
373
|
+
"Error parsing ([a-zA-Z]:)?/tmp/.kitchen.yml")
|
|
392
374
|
end
|
|
393
375
|
|
|
394
376
|
it "raises a UserError if kitchen.yml cannot be parsed" do
|
|
@@ -397,20 +379,20 @@ describe Kitchen::Loader::YAML do
|
|
|
397
379
|
|
|
398
380
|
err = proc { loader.read }.must_raise Kitchen::UserError
|
|
399
381
|
err.message.must_match Regexp.new(
|
|
400
|
-
"Error parsing ([a-zA-Z]:)
|
|
382
|
+
"Error parsing ([a-zA-Z]:)?/tmp/.kitchen.yml")
|
|
401
383
|
end
|
|
402
384
|
|
|
403
385
|
it "handles a kitchen.yml if it is a commented out YAML document" do
|
|
404
386
|
FileUtils.mkdir_p "/tmp"
|
|
405
387
|
File.open("/tmp/.kitchen.yml", "wb") { |f| f.write '#---\n' }
|
|
406
388
|
|
|
407
|
-
loader.read.must_equal(
|
|
389
|
+
loader.read.must_equal({})
|
|
408
390
|
end
|
|
409
391
|
|
|
410
392
|
it "raises a UserError if kitchen.local.yml cannot be parsed" do
|
|
411
393
|
FileUtils.mkdir_p "/tmp"
|
|
412
394
|
File.open("/tmp/.kitchen.local.yml", "wb") { |f| f.write "&*%^*" }
|
|
413
|
-
stub_yaml!(
|
|
395
|
+
stub_yaml!({})
|
|
414
396
|
|
|
415
397
|
proc { loader.read }.must_raise Kitchen::UserError
|
|
416
398
|
end
|
|
@@ -424,7 +406,7 @@ describe Kitchen::Loader::YAML do
|
|
|
424
406
|
YAML
|
|
425
407
|
end
|
|
426
408
|
|
|
427
|
-
loader.read.must_equal(:
|
|
409
|
+
loader.read.must_equal(name: "ahhchoo")
|
|
428
410
|
end
|
|
429
411
|
|
|
430
412
|
it "raises a UserError if there is an ERB processing error" do
|
|
@@ -438,7 +420,7 @@ describe Kitchen::Loader::YAML do
|
|
|
438
420
|
|
|
439
421
|
err = proc { loader.read }.must_raise Kitchen::UserError
|
|
440
422
|
err.message.must_match Regexp.new(
|
|
441
|
-
"Error parsing ERB content in ([a-zA-Z]:)
|
|
423
|
+
"Error parsing ERB content in ([a-zA-Z]:)?/tmp/.kitchen.yml")
|
|
442
424
|
end
|
|
443
425
|
|
|
444
426
|
it "evaluates kitchen.local.yml through erb before loading by default" do
|
|
@@ -451,18 +433,18 @@ describe Kitchen::Loader::YAML do
|
|
|
451
433
|
<% end %>
|
|
452
434
|
YAML
|
|
453
435
|
end
|
|
454
|
-
stub_yaml!("
|
|
436
|
+
stub_yaml!("spinach" => "salad")
|
|
455
437
|
|
|
456
438
|
loader.read.must_equal(
|
|
457
|
-
:
|
|
458
|
-
:
|
|
459
|
-
:
|
|
439
|
+
spinach: "salad",
|
|
440
|
+
noodle: "soup",
|
|
441
|
+
mushroom: "soup"
|
|
460
442
|
)
|
|
461
443
|
end
|
|
462
444
|
|
|
463
445
|
it "skips evaluating kitchen.yml through erb if disabled" do
|
|
464
446
|
loader = Kitchen::Loader::YAML.new(
|
|
465
|
-
:
|
|
447
|
+
project_config: "/tmp/.kitchen.yml", process_erb: false)
|
|
466
448
|
FileUtils.mkdir_p "/tmp"
|
|
467
449
|
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
|
468
450
|
f.write <<-'YAML'.gsub(/^ {10}/, "")
|
|
@@ -471,12 +453,12 @@ describe Kitchen::Loader::YAML do
|
|
|
471
453
|
YAML
|
|
472
454
|
end
|
|
473
455
|
|
|
474
|
-
loader.read.must_equal(:
|
|
456
|
+
loader.read.must_equal(name: '<%= "AHH".downcase %>')
|
|
475
457
|
end
|
|
476
458
|
|
|
477
459
|
it "skips evaluating kitchen.local.yml through erb if disabled" do
|
|
478
460
|
loader = Kitchen::Loader::YAML.new(
|
|
479
|
-
:
|
|
461
|
+
project_config: "/tmp/.kitchen.yml", process_erb: false)
|
|
480
462
|
FileUtils.mkdir_p "/tmp"
|
|
481
463
|
File.open("/tmp/.kitchen.local.yml", "wb") do |f|
|
|
482
464
|
f.write <<-'YAML'.gsub(/^ {10}/, "")
|
|
@@ -484,98 +466,94 @@ describe Kitchen::Loader::YAML do
|
|
|
484
466
|
name: <%= "AHH".downcase %>
|
|
485
467
|
YAML
|
|
486
468
|
end
|
|
487
|
-
stub_yaml!(
|
|
469
|
+
stub_yaml!({})
|
|
488
470
|
|
|
489
|
-
loader.read.must_equal(:
|
|
471
|
+
loader.read.must_equal(name: '<%= "AHH".downcase %>')
|
|
490
472
|
end
|
|
491
473
|
|
|
492
474
|
it "skips kitchen.local.yml if disabled" do
|
|
493
475
|
loader = Kitchen::Loader::YAML.new(
|
|
494
|
-
:
|
|
495
|
-
stub_yaml!("
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
"superawesomesauceadditions" => "enabled, yo"
|
|
476
|
+
project_config: "/tmp/.kitchen.yml", process_local: false)
|
|
477
|
+
stub_yaml!("a" => "b")
|
|
478
|
+
stub_yaml!(
|
|
479
|
+
{ "superawesomesauceadditions" => "enabled, yo" },
|
|
480
|
+
".kitchen.local.yml"
|
|
500
481
|
)
|
|
501
482
|
|
|
502
|
-
loader.read.must_equal(:
|
|
483
|
+
loader.read.must_equal(a: "b")
|
|
503
484
|
end
|
|
504
485
|
|
|
505
486
|
it "skips the global config if disabled" do
|
|
506
487
|
loader = Kitchen::Loader::YAML.new(
|
|
507
|
-
:
|
|
508
|
-
stub_yaml!("
|
|
509
|
-
"a" => "b"
|
|
510
|
-
)
|
|
488
|
+
project_config: "/tmp/.kitchen.yml", process_global: false)
|
|
489
|
+
stub_yaml!("a" => "b")
|
|
511
490
|
stub_global!(
|
|
512
491
|
"superawesomesauceadditions" => "enabled, yo"
|
|
513
492
|
)
|
|
514
493
|
|
|
515
|
-
loader.read.must_equal(:
|
|
494
|
+
loader.read.must_equal(a: "b")
|
|
516
495
|
end
|
|
517
496
|
end
|
|
518
497
|
|
|
519
498
|
describe "#diagnose" do
|
|
520
|
-
|
|
521
499
|
it "returns a Hash" do
|
|
522
|
-
stub_yaml!(
|
|
500
|
+
stub_yaml!({})
|
|
523
501
|
|
|
524
502
|
loader.diagnose.must_be_kind_of(Hash)
|
|
525
503
|
end
|
|
526
504
|
|
|
527
505
|
it "contains erb processing information when true" do
|
|
528
|
-
stub_yaml!(
|
|
506
|
+
stub_yaml!({})
|
|
529
507
|
|
|
530
508
|
loader.diagnose[:process_erb].must_equal true
|
|
531
509
|
end
|
|
532
510
|
|
|
533
511
|
it "contains erb processing information when false" do
|
|
534
|
-
stub_yaml!(
|
|
512
|
+
stub_yaml!({})
|
|
535
513
|
loader = Kitchen::Loader::YAML.new(
|
|
536
|
-
:
|
|
514
|
+
project_config: "/tmp/.kitchen.yml", process_erb: false)
|
|
537
515
|
|
|
538
516
|
loader.diagnose[:process_erb].must_equal false
|
|
539
517
|
end
|
|
540
518
|
|
|
541
519
|
it "contains local processing information when true" do
|
|
542
|
-
stub_yaml!(
|
|
520
|
+
stub_yaml!({})
|
|
543
521
|
|
|
544
522
|
loader.diagnose[:process_local].must_equal true
|
|
545
523
|
end
|
|
546
524
|
|
|
547
525
|
it "contains local processing information when false" do
|
|
548
|
-
stub_yaml!(
|
|
526
|
+
stub_yaml!({})
|
|
549
527
|
loader = Kitchen::Loader::YAML.new(
|
|
550
|
-
:
|
|
528
|
+
project_config: "/tmp/.kitchen.yml", process_local: false)
|
|
551
529
|
|
|
552
530
|
loader.diagnose[:process_local].must_equal false
|
|
553
531
|
end
|
|
554
532
|
|
|
555
533
|
it "contains global processing information when true" do
|
|
556
|
-
stub_yaml!(
|
|
534
|
+
stub_yaml!({})
|
|
557
535
|
|
|
558
536
|
loader.diagnose[:process_global].must_equal true
|
|
559
537
|
end
|
|
560
538
|
|
|
561
539
|
it "contains global processing information when false" do
|
|
562
|
-
stub_yaml!(
|
|
540
|
+
stub_yaml!({})
|
|
563
541
|
loader = Kitchen::Loader::YAML.new(
|
|
564
|
-
:
|
|
542
|
+
project_config: "/tmp/.kitchen.yml", process_global: false)
|
|
565
543
|
|
|
566
544
|
loader.diagnose[:process_global].must_equal false
|
|
567
545
|
end
|
|
568
546
|
|
|
569
547
|
describe "for yaml files" do
|
|
570
|
-
|
|
571
548
|
before do
|
|
572
|
-
stub_yaml!("
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
549
|
+
stub_yaml!("from_project" => "project",
|
|
550
|
+
"common" => { "p" => "pretty" }
|
|
551
|
+
)
|
|
552
|
+
stub_yaml!({
|
|
553
|
+
"from_local" => "local",
|
|
554
|
+
"common" => { "l" => "looky" },
|
|
555
|
+
},
|
|
556
|
+
".kitchen.local.yml"
|
|
579
557
|
)
|
|
580
558
|
stub_global!(
|
|
581
559
|
"from_global" => "global",
|
|
@@ -584,8 +562,8 @@ describe Kitchen::Loader::YAML do
|
|
|
584
562
|
end
|
|
585
563
|
|
|
586
564
|
it "global config contains a filename" do
|
|
587
|
-
loader.diagnose[:global_config][:filename]
|
|
588
|
-
must_equal File.join(ENV["HOME"].
|
|
565
|
+
loader.diagnose[:global_config][:filename]
|
|
566
|
+
.must_equal File.join(ENV["HOME"].tr('\\', "/"), ".kitchen/config.yml")
|
|
589
567
|
end
|
|
590
568
|
|
|
591
569
|
it "global config contains raw data" do
|
|
@@ -596,8 +574,8 @@ describe Kitchen::Loader::YAML do
|
|
|
596
574
|
end
|
|
597
575
|
|
|
598
576
|
it "project config contains a filename" do
|
|
599
|
-
loader.diagnose[:project_config][:filename]
|
|
600
|
-
must_match %r{/tmp/.kitchen.yml$}
|
|
577
|
+
loader.diagnose[:project_config][:filename]
|
|
578
|
+
.must_match %r{/tmp/.kitchen.yml$}
|
|
601
579
|
end
|
|
602
580
|
|
|
603
581
|
it "project config contains raw data" do
|
|
@@ -608,8 +586,8 @@ describe Kitchen::Loader::YAML do
|
|
|
608
586
|
end
|
|
609
587
|
|
|
610
588
|
it "local config contains a filename" do
|
|
611
|
-
loader.diagnose[:local_config][:filename]
|
|
612
|
-
must_match %r{/tmp/.kitchen.local.yml$}
|
|
589
|
+
loader.diagnose[:local_config][:filename]
|
|
590
|
+
.must_match %r{/tmp/.kitchen.local.yml$}
|
|
613
591
|
end
|
|
614
592
|
|
|
615
593
|
it "local config contains raw data" do
|
|
@@ -620,8 +598,8 @@ describe Kitchen::Loader::YAML do
|
|
|
620
598
|
end
|
|
621
599
|
|
|
622
600
|
it "combined config contains a nil filename" do
|
|
623
|
-
loader.diagnose[:combined_config][:filename]
|
|
624
|
-
must_equal nil
|
|
601
|
+
loader.diagnose[:combined_config][:filename]
|
|
602
|
+
.must_equal nil
|
|
625
603
|
end
|
|
626
604
|
|
|
627
605
|
it "combined config contains raw data" do
|
|
@@ -632,13 +610,12 @@ describe Kitchen::Loader::YAML do
|
|
|
632
610
|
"common" => {
|
|
633
611
|
"g" => "goody",
|
|
634
612
|
"p" => "pretty",
|
|
635
|
-
"l" => "looky"
|
|
613
|
+
"l" => "looky",
|
|
636
614
|
}
|
|
637
615
|
)
|
|
638
616
|
end
|
|
639
617
|
|
|
640
618
|
describe "for global on error" do
|
|
641
|
-
|
|
642
619
|
before do
|
|
643
620
|
FileUtils.mkdir_p(File.join(ENV["HOME"], ".kitchen"))
|
|
644
621
|
File.open(File.join(ENV["HOME"], ".kitchen/config.yml"), "wb") do |f|
|
|
@@ -647,28 +624,27 @@ describe Kitchen::Loader::YAML do
|
|
|
647
624
|
end
|
|
648
625
|
|
|
649
626
|
it "uses an error hash with the raw file contents" do
|
|
650
|
-
loader.diagnose[:global_config][:raw_data][:error][:raw_file]
|
|
651
|
-
must_equal "&*%^*"
|
|
627
|
+
loader.diagnose[:global_config][:raw_data][:error][:raw_file]
|
|
628
|
+
.must_equal "&*%^*"
|
|
652
629
|
end
|
|
653
630
|
|
|
654
631
|
it "uses an error hash with the exception" do
|
|
655
|
-
loader.diagnose[:global_config][:raw_data][:error][:exception]
|
|
656
|
-
must_match
|
|
632
|
+
loader.diagnose[:global_config][:raw_data][:error][:exception]
|
|
633
|
+
.must_match /Kitchen::UserError/
|
|
657
634
|
end
|
|
658
635
|
|
|
659
636
|
it "uses an error hash with the exception message" do
|
|
660
|
-
loader.diagnose[:global_config][:raw_data][:error][:message]
|
|
661
|
-
must_match
|
|
637
|
+
loader.diagnose[:global_config][:raw_data][:error][:message]
|
|
638
|
+
.must_match /Error parsing/
|
|
662
639
|
end
|
|
663
640
|
|
|
664
641
|
it "uses an error hash with the exception backtrace" do
|
|
665
|
-
loader.diagnose[:global_config][:raw_data][:error][:backtrace]
|
|
666
|
-
must_be_kind_of Array
|
|
642
|
+
loader.diagnose[:global_config][:raw_data][:error][:backtrace]
|
|
643
|
+
.must_be_kind_of Array
|
|
667
644
|
end
|
|
668
645
|
end
|
|
669
646
|
|
|
670
647
|
describe "for project on error" do
|
|
671
|
-
|
|
672
648
|
before do
|
|
673
649
|
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
|
674
650
|
f.write "&*%^*"
|
|
@@ -676,28 +652,27 @@ describe Kitchen::Loader::YAML do
|
|
|
676
652
|
end
|
|
677
653
|
|
|
678
654
|
it "uses an error hash with the raw file contents" do
|
|
679
|
-
loader.diagnose[:project_config][:raw_data][:error][:raw_file]
|
|
680
|
-
must_equal "&*%^*"
|
|
655
|
+
loader.diagnose[:project_config][:raw_data][:error][:raw_file]
|
|
656
|
+
.must_equal "&*%^*"
|
|
681
657
|
end
|
|
682
658
|
|
|
683
659
|
it "uses an error hash with the exception" do
|
|
684
|
-
loader.diagnose[:project_config][:raw_data][:error][:exception]
|
|
685
|
-
must_match
|
|
660
|
+
loader.diagnose[:project_config][:raw_data][:error][:exception]
|
|
661
|
+
.must_match /Kitchen::UserError/
|
|
686
662
|
end
|
|
687
663
|
|
|
688
664
|
it "uses an error hash with the exception message" do
|
|
689
|
-
loader.diagnose[:project_config][:raw_data][:error][:message]
|
|
690
|
-
must_match
|
|
665
|
+
loader.diagnose[:project_config][:raw_data][:error][:message]
|
|
666
|
+
.must_match /Error parsing/
|
|
691
667
|
end
|
|
692
668
|
|
|
693
669
|
it "uses an error hash with the exception backtrace" do
|
|
694
|
-
loader.diagnose[:project_config][:raw_data][:error][:backtrace]
|
|
695
|
-
must_be_kind_of Array
|
|
670
|
+
loader.diagnose[:project_config][:raw_data][:error][:backtrace]
|
|
671
|
+
.must_be_kind_of Array
|
|
696
672
|
end
|
|
697
673
|
end
|
|
698
674
|
|
|
699
675
|
describe "for local on error" do
|
|
700
|
-
|
|
701
676
|
before do
|
|
702
677
|
File.open("/tmp/.kitchen.local.yml", "wb") do |f|
|
|
703
678
|
f.write "&*%^*"
|
|
@@ -705,28 +680,27 @@ describe Kitchen::Loader::YAML do
|
|
|
705
680
|
end
|
|
706
681
|
|
|
707
682
|
it "uses an error hash with the raw file contents" do
|
|
708
|
-
loader.diagnose[:local_config][:raw_data][:error][:raw_file]
|
|
709
|
-
must_equal "&*%^*"
|
|
683
|
+
loader.diagnose[:local_config][:raw_data][:error][:raw_file]
|
|
684
|
+
.must_equal "&*%^*"
|
|
710
685
|
end
|
|
711
686
|
|
|
712
687
|
it "uses an error hash with the exception" do
|
|
713
|
-
loader.diagnose[:local_config][:raw_data][:error][:exception]
|
|
714
|
-
must_match
|
|
688
|
+
loader.diagnose[:local_config][:raw_data][:error][:exception]
|
|
689
|
+
.must_match /Kitchen::UserError/
|
|
715
690
|
end
|
|
716
691
|
|
|
717
692
|
it "uses an error hash with the exception message" do
|
|
718
|
-
loader.diagnose[:local_config][:raw_data][:error][:message]
|
|
719
|
-
must_match
|
|
693
|
+
loader.diagnose[:local_config][:raw_data][:error][:message]
|
|
694
|
+
.must_match /Error parsing/
|
|
720
695
|
end
|
|
721
696
|
|
|
722
697
|
it "uses an error hash with the exception backtrace" do
|
|
723
|
-
loader.diagnose[:local_config][:raw_data][:error][:backtrace]
|
|
724
|
-
must_be_kind_of Array
|
|
698
|
+
loader.diagnose[:local_config][:raw_data][:error][:backtrace]
|
|
699
|
+
.must_be_kind_of Array
|
|
725
700
|
end
|
|
726
701
|
end
|
|
727
702
|
|
|
728
703
|
describe "for combined on error" do
|
|
729
|
-
|
|
730
704
|
before do
|
|
731
705
|
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
|
732
706
|
f.write "&*%^*"
|
|
@@ -734,23 +708,23 @@ describe Kitchen::Loader::YAML do
|
|
|
734
708
|
end
|
|
735
709
|
|
|
736
710
|
it "uses an error hash with nil raw file contents" do
|
|
737
|
-
loader.diagnose[:combined_config][:raw_data][:error][:raw_file]
|
|
738
|
-
must_equal nil
|
|
711
|
+
loader.diagnose[:combined_config][:raw_data][:error][:raw_file]
|
|
712
|
+
.must_equal nil
|
|
739
713
|
end
|
|
740
714
|
|
|
741
715
|
it "uses an error hash with the exception" do
|
|
742
|
-
loader.diagnose[:combined_config][:raw_data][:error][:exception]
|
|
743
|
-
must_match
|
|
716
|
+
loader.diagnose[:combined_config][:raw_data][:error][:exception]
|
|
717
|
+
.must_match /Kitchen::UserError/
|
|
744
718
|
end
|
|
745
719
|
|
|
746
720
|
it "uses an error hash with the exception message" do
|
|
747
|
-
loader.diagnose[:combined_config][:raw_data][:error][:message]
|
|
748
|
-
must_match
|
|
721
|
+
loader.diagnose[:combined_config][:raw_data][:error][:message]
|
|
722
|
+
.must_match /Error parsing/
|
|
749
723
|
end
|
|
750
724
|
|
|
751
725
|
it "uses an error hash with the exception backtrace" do
|
|
752
|
-
loader.diagnose[:combined_config][:raw_data][:error][:backtrace]
|
|
753
|
-
must_be_kind_of Array
|
|
726
|
+
loader.diagnose[:combined_config][:raw_data][:error][:backtrace]
|
|
727
|
+
.must_be_kind_of Array
|
|
754
728
|
end
|
|
755
729
|
end
|
|
756
730
|
end
|
|
@@ -763,12 +737,12 @@ describe Kitchen::Loader::YAML do
|
|
|
763
737
|
File.open(path, "wb") { |f| f.write(hash.to_yaml) }
|
|
764
738
|
end
|
|
765
739
|
|
|
766
|
-
def stub_yaml!(name = ".kitchen.yml"
|
|
740
|
+
def stub_yaml!(hash, name = ".kitchen.yml")
|
|
767
741
|
stub_file(File.join("/tmp", name), hash)
|
|
768
742
|
end
|
|
769
743
|
|
|
770
744
|
def stub_global!(hash)
|
|
771
745
|
stub_file(File.join(File.expand_path(ENV["HOME"]),
|
|
772
|
-
|
|
746
|
+
".kitchen", "config.yml"), hash)
|
|
773
747
|
end
|
|
774
748
|
end
|