test-kitchen 1.14.1 → 1.14.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -25,14 +25,11 @@ require "kitchen/provisioner"
|
|
25
25
|
require "kitchen/provisioner/base"
|
26
26
|
|
27
27
|
module Kitchen
|
28
|
-
|
29
28
|
module Provisioner
|
30
|
-
|
31
29
|
class Coolbeans < Kitchen::Provisioner::Base
|
32
30
|
end
|
33
31
|
|
34
32
|
class ItDepends < Kitchen::Provisioner::Base
|
35
|
-
|
36
33
|
attr_reader :verify_call_count
|
37
34
|
|
38
35
|
def initialize(config = {})
|
@@ -46,7 +43,6 @@ module Kitchen
|
|
46
43
|
end
|
47
44
|
|
48
45
|
class UnstableDepends < Kitchen::Provisioner::Base
|
49
|
-
|
50
46
|
def verify_dependencies
|
51
47
|
raise UserError, "Oh noes, you don't have software!"
|
52
48
|
end
|
@@ -55,9 +51,7 @@ module Kitchen
|
|
55
51
|
end
|
56
52
|
|
57
53
|
describe Kitchen::Provisioner do
|
58
|
-
|
59
54
|
describe ".for_plugin" do
|
60
|
-
|
61
55
|
before do
|
62
56
|
Kitchen::Provisioner.stubs(:require).returns(true)
|
63
57
|
end
|
@@ -69,7 +63,7 @@ describe Kitchen::Provisioner do
|
|
69
63
|
end
|
70
64
|
|
71
65
|
it "returns a provisioner initialized with its config" do
|
72
|
-
provisioner = Kitchen::Provisioner.for_plugin("coolbeans", :
|
66
|
+
provisioner = Kitchen::Provisioner.for_plugin("coolbeans", foo: "bar")
|
73
67
|
|
74
68
|
provisioner[:foo].must_equal "bar"
|
75
69
|
end
|
@@ -92,16 +86,16 @@ describe Kitchen::Provisioner do
|
|
92
86
|
it "raises ClientError if the provisioner could not be required" do
|
93
87
|
Kitchen::Provisioner.stubs(:require).raises(LoadError)
|
94
88
|
|
95
|
-
proc { Kitchen::Provisioner.for_plugin("coolbeans", {}) }
|
96
|
-
must_raise Kitchen::ClientError
|
89
|
+
proc { Kitchen::Provisioner.for_plugin("coolbeans", {}) }
|
90
|
+
.must_raise Kitchen::ClientError
|
97
91
|
end
|
98
92
|
|
99
93
|
it "raises ClientError if the provisioner's class constant was not found" do
|
100
94
|
# pretend require worked
|
101
95
|
Kitchen::Provisioner.stubs(:require).returns(true)
|
102
96
|
|
103
|
-
proc { Kitchen::Provisioner.for_plugin("nope", {}) }
|
104
|
-
must_raise Kitchen::ClientError
|
97
|
+
proc { Kitchen::Provisioner.for_plugin("nope", {}) }
|
98
|
+
.must_raise Kitchen::ClientError
|
105
99
|
end
|
106
100
|
end
|
107
101
|
end
|
@@ -23,9 +23,7 @@ require "kitchen/shell_out"
|
|
23
23
|
require "kitchen/util"
|
24
24
|
|
25
25
|
module Kitchen
|
26
|
-
|
27
26
|
class Shelly
|
28
|
-
|
29
27
|
include Kitchen::ShellOut
|
30
28
|
|
31
29
|
attr_reader :logs
|
@@ -42,22 +40,20 @@ module Kitchen
|
|
42
40
|
end
|
43
41
|
|
44
42
|
describe Kitchen::ShellOut do
|
45
|
-
|
46
43
|
let(:command) do
|
47
44
|
stub(
|
48
|
-
:
|
49
|
-
|
50
|
-
:
|
51
|
-
:
|
45
|
+
run_command: true,
|
46
|
+
error!: true,
|
47
|
+
stdout: "",
|
48
|
+
execution_time: 123
|
52
49
|
)
|
53
50
|
end
|
54
51
|
|
55
52
|
let(:subject) { Kitchen::Shelly.new }
|
56
53
|
|
57
54
|
describe "#run_command" do
|
58
|
-
|
59
55
|
let(:opts) do
|
60
|
-
{ :
|
56
|
+
{ live_stream: "alogger", timeout: 60_000 }
|
61
57
|
end
|
62
58
|
|
63
59
|
before do
|
@@ -89,11 +85,11 @@ describe Kitchen::ShellOut do
|
|
89
85
|
end
|
90
86
|
|
91
87
|
it "raises a ShellCommandFailed if the command does not cleanly exit" do
|
92
|
-
command.stubs(:error!)
|
93
|
-
|
88
|
+
command.stubs(:error!)
|
89
|
+
.raises(Mixlib::ShellOut::ShellCommandFailed, "boom bad")
|
94
90
|
|
95
|
-
err = proc { subject.run_command("boom") }
|
96
|
-
|
91
|
+
err = proc { subject.run_command("boom") }
|
92
|
+
.must_raise Kitchen::ShellOut::ShellCommandFailed
|
97
93
|
err.message.must_equal "boom bad"
|
98
94
|
end
|
99
95
|
|
@@ -109,25 +105,25 @@ describe Kitchen::ShellOut do
|
|
109
105
|
Mixlib::ShellOut.unstub(:new)
|
110
106
|
Mixlib::ShellOut.expects(:new).with("sudo -E yo", opts).returns(command)
|
111
107
|
|
112
|
-
subject.run_command("yo", :
|
108
|
+
subject.run_command("yo", use_sudo: true)
|
113
109
|
end
|
114
110
|
|
115
111
|
it "prepends with custom :sudo_command if :use_sudo is truthy" do
|
116
112
|
Mixlib::ShellOut.unstub(:new)
|
117
113
|
Mixlib::ShellOut.expects(:new).with("wat yo", opts).returns(command)
|
118
114
|
|
119
|
-
subject.run_command("yo", :
|
115
|
+
subject.run_command("yo", use_sudo: true, sudo_command: "wat")
|
120
116
|
end
|
121
117
|
|
122
118
|
it "logs a debug BEGIN message" do
|
123
119
|
subject.run_command("echo whoopa\ndoopa\ndo")
|
124
120
|
|
125
|
-
subject.logs.first
|
126
|
-
|
121
|
+
subject.logs.first
|
122
|
+
.must_equal "[local command] BEGIN (echo whoopa\ndoopa\ndo)"
|
127
123
|
end
|
128
124
|
|
129
125
|
it "logs a debug BEGIN message with custom log subject" do
|
130
|
-
subject.run_command("tenac", :
|
126
|
+
subject.run_command("tenac", log_subject: "thed")
|
131
127
|
|
132
128
|
subject.logs.first.must_equal "[thed command] BEGIN (tenac)"
|
133
129
|
end
|
@@ -142,7 +138,7 @@ describe Kitchen::ShellOut do
|
|
142
138
|
end
|
143
139
|
|
144
140
|
it "logs a debug END message with custom log subject" do
|
145
|
-
subject.run_command("tenac", :
|
141
|
+
subject.run_command("tenac", log_subject: "thed")
|
146
142
|
|
147
143
|
subject.logs.last.must_equal "[thed command] END (2m3.00s)"
|
148
144
|
end
|
data/spec/kitchen/ssh_spec.rb
CHANGED
@@ -87,13 +87,9 @@ end
|
|
87
87
|
# An upstream patch to Net::SSH will be required to retire this yak shave ;)
|
88
88
|
require "net/ssh/test/channel"
|
89
89
|
module Net
|
90
|
-
|
91
90
|
module SSH
|
92
|
-
|
93
91
|
module Test
|
94
|
-
|
95
92
|
class Channel
|
96
|
-
|
97
93
|
def sends_request_pty
|
98
94
|
pty_data = ["xterm", 80, 24, 640, 480, "\0"]
|
99
95
|
|
@@ -116,7 +112,6 @@ module Net
|
|
116
112
|
end
|
117
113
|
|
118
114
|
describe Kitchen::SSH do
|
119
|
-
|
120
115
|
include Net::SSH::Test
|
121
116
|
|
122
117
|
let(:logged_output) { StringIO.new }
|
@@ -137,14 +132,12 @@ describe Kitchen::SSH do
|
|
137
132
|
end
|
138
133
|
|
139
134
|
describe "establishing a connection" do
|
140
|
-
|
141
135
|
[
|
142
136
|
Errno::EACCES, Errno::EADDRINUSE, Errno::ECONNREFUSED,
|
143
137
|
Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH,
|
144
138
|
Net::SSH::Disconnect, Net::SSH::AuthenticationFailed, Net::SSH::ConnectionTimeout
|
145
139
|
].each do |klass|
|
146
140
|
describe "raising #{klass}" do
|
147
|
-
|
148
141
|
before do
|
149
142
|
Net::SSH.stubs(:start).raises(klass)
|
150
143
|
opts[:ssh_retries] = 3
|
@@ -161,9 +154,9 @@ describe Kitchen::SSH do
|
|
161
154
|
rescue # rubocop:disable Lint/HandleExceptions
|
162
155
|
end
|
163
156
|
|
164
|
-
logged_output.string.lines.count
|
157
|
+
logged_output.string.lines.count do |l|
|
165
158
|
l =~ debug_line("[SSH] opening connection to me@foo:22<{:ssh_retries=>3}>")
|
166
|
-
|
159
|
+
end.must_equal opts[:ssh_retries]
|
167
160
|
end
|
168
161
|
|
169
162
|
it "sleeps for 1 second between retries" do
|
@@ -182,9 +175,9 @@ describe Kitchen::SSH do
|
|
182
175
|
rescue # rubocop:disable Lint/HandleExceptions
|
183
176
|
end
|
184
177
|
|
185
|
-
logged_output.string.lines.count
|
178
|
+
logged_output.string.lines.count do |l|
|
186
179
|
l =~ info_line_with("[SSH] connection failed, retrying ")
|
187
|
-
|
180
|
+
end.must_equal 2
|
188
181
|
end
|
189
182
|
|
190
183
|
it "logs the last retry failures on warn" do
|
@@ -193,18 +186,16 @@ describe Kitchen::SSH do
|
|
193
186
|
rescue # rubocop:disable Lint/HandleExceptions
|
194
187
|
end
|
195
188
|
|
196
|
-
logged_output.string.lines.count
|
189
|
+
logged_output.string.lines.count do |l|
|
197
190
|
l =~ warn_line_with("[SSH] connection failed, terminating ")
|
198
|
-
|
191
|
+
end.must_equal 1
|
199
192
|
end
|
200
193
|
end
|
201
194
|
end
|
202
195
|
end
|
203
196
|
|
204
197
|
describe "#exec" do
|
205
|
-
|
206
198
|
describe "for a successful command" do
|
207
|
-
|
208
199
|
before do
|
209
200
|
story do |script|
|
210
201
|
channel = script.opens_channel
|
@@ -248,7 +239,6 @@ describe Kitchen::SSH do
|
|
248
239
|
end
|
249
240
|
|
250
241
|
describe "for a failed command" do
|
251
|
-
|
252
242
|
before do
|
253
243
|
story do |script|
|
254
244
|
channel = script.opens_channel
|
@@ -310,7 +300,6 @@ describe Kitchen::SSH do
|
|
310
300
|
end
|
311
301
|
|
312
302
|
describe "#upload!" do
|
313
|
-
|
314
303
|
let(:content) { "a" * 1234 }
|
315
304
|
|
316
305
|
let(:src) do
|
@@ -358,7 +347,6 @@ describe Kitchen::SSH do
|
|
358
347
|
end
|
359
348
|
|
360
349
|
describe "#upload_path!" do
|
361
|
-
|
362
350
|
before do
|
363
351
|
@dir = Dir.mktmpdir("local")
|
364
352
|
|
@@ -438,7 +426,6 @@ describe Kitchen::SSH do
|
|
438
426
|
end
|
439
427
|
|
440
428
|
describe "#shutdown" do
|
441
|
-
|
442
429
|
before do
|
443
430
|
story do |script|
|
444
431
|
channel = script.opens_channel
|
@@ -477,7 +464,6 @@ describe Kitchen::SSH do
|
|
477
464
|
end
|
478
465
|
|
479
466
|
describe "block form" do
|
480
|
-
|
481
467
|
before do
|
482
468
|
story do |script|
|
483
469
|
channel = script.opens_channel
|
@@ -500,7 +486,6 @@ describe Kitchen::SSH do
|
|
500
486
|
end
|
501
487
|
|
502
488
|
describe "#login_command" do
|
503
|
-
|
504
489
|
let(:login_command) { ssh.login_command }
|
505
490
|
let(:args) { login_command.arguments.join(" ") }
|
506
491
|
|
@@ -566,7 +551,7 @@ describe Kitchen::SSH do
|
|
566
551
|
end
|
567
552
|
|
568
553
|
it "sets SSH keys options if given" do
|
569
|
-
opts[:keys] = %w
|
554
|
+
opts[:keys] = %w{one two}
|
570
555
|
|
571
556
|
args.must_match regexify(" -i one ")
|
572
557
|
args.must_match regexify(" -i two ")
|
@@ -584,8 +569,7 @@ describe Kitchen::SSH do
|
|
584
569
|
end
|
585
570
|
|
586
571
|
describe "#test_ssh" do
|
587
|
-
|
588
|
-
let(:tcp_socket) { stub(:select_for_read? => true, :close => true) }
|
572
|
+
let(:tcp_socket) { stub(select_for_read?: true, close: true) }
|
589
573
|
|
590
574
|
before { ssh.stubs(:sleep) }
|
591
575
|
|
@@ -609,7 +593,6 @@ describe Kitchen::SSH do
|
|
609
593
|
Errno::ENETUNREACH, IOError
|
610
594
|
].each do |klass|
|
611
595
|
describe "when #{klass} is raised" do
|
612
|
-
|
613
596
|
before { TCPSocket.stubs(:new).raises(klass) }
|
614
597
|
|
615
598
|
it "returns false" do
|
@@ -628,7 +611,6 @@ describe Kitchen::SSH do
|
|
628
611
|
Errno::EPERM, Errno::ETIMEDOUT
|
629
612
|
].each do |klass|
|
630
613
|
describe "when #{klass} is raised" do
|
631
|
-
|
632
614
|
it "returns false when #{klass} is raised" do
|
633
615
|
TCPSocket.stubs(:new).raises(klass)
|
634
616
|
|
@@ -639,22 +621,21 @@ describe Kitchen::SSH do
|
|
639
621
|
end
|
640
622
|
|
641
623
|
describe "#wait" do
|
642
|
-
|
643
624
|
let(:not_ready) do
|
644
|
-
stub(
|
625
|
+
stub(select_for_read?: false, idle!: true, close: true)
|
645
626
|
end
|
646
627
|
|
647
628
|
let(:ready) do
|
648
|
-
stub(
|
629
|
+
stub(select_for_read?: true, close: true)
|
649
630
|
end
|
650
631
|
|
651
632
|
it "logs to info for each retry" do
|
652
633
|
TCPSocket.stubs(:new).returns(not_ready, not_ready, ready)
|
653
634
|
ssh.wait
|
654
635
|
|
655
|
-
logged_output.string.lines.count
|
636
|
+
logged_output.string.lines.count do |l|
|
656
637
|
l =~ info_line_with("Waiting for foo:22...")
|
657
|
-
|
638
|
+
end.must_equal 2
|
658
639
|
end
|
659
640
|
end
|
660
641
|
|
@@ -676,18 +657,18 @@ describe Kitchen::SSH do
|
|
676
657
|
end
|
677
658
|
|
678
659
|
def debug_line(msg)
|
679
|
-
|
660
|
+
/^D, .* : #{Regexp.escape(msg)}$/
|
680
661
|
end
|
681
662
|
|
682
663
|
def debug_line_with(msg)
|
683
|
-
|
664
|
+
/^D, .* : #{Regexp.escape(msg)}/
|
684
665
|
end
|
685
666
|
|
686
667
|
def info_line_with(msg)
|
687
|
-
|
668
|
+
/^I, .* : #{Regexp.escape(msg)}/
|
688
669
|
end
|
689
670
|
|
690
671
|
def warn_line_with(msg)
|
691
|
-
|
672
|
+
/^W, .* : #{Regexp.escape(msg)}/
|
692
673
|
end
|
693
674
|
end
|
@@ -27,7 +27,6 @@ class YamledState
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe Kitchen::StateFile do
|
30
|
-
|
31
30
|
let(:state_file) { Kitchen::StateFile.new("/tmp", "oftheunion") }
|
32
31
|
let(:file_name) { "/tmp/.kitchen/oftheunion.yml" }
|
33
32
|
|
@@ -42,23 +41,22 @@ describe Kitchen::StateFile do
|
|
42
41
|
end
|
43
42
|
|
44
43
|
describe "#read" do
|
45
|
-
|
46
44
|
it "returns an empty hash if the file does not exist" do
|
47
|
-
state_file.read.must_equal(
|
45
|
+
state_file.read.must_equal({})
|
48
46
|
end
|
49
47
|
|
50
48
|
it "returns and empty hash if the file is zero length" do
|
51
49
|
stub_state_file!("")
|
52
50
|
|
53
|
-
state_file.read.must_equal(
|
51
|
+
state_file.read.must_equal({})
|
54
52
|
end
|
55
53
|
|
56
54
|
it "returns a Hash with symbolized keys from the state file" do
|
57
55
|
stub_state_file!
|
58
56
|
|
59
57
|
state_file.read.must_equal(
|
60
|
-
:
|
61
|
-
:
|
58
|
+
cloud_id: 42,
|
59
|
+
flavor: "extra_crispy"
|
62
60
|
)
|
63
61
|
end
|
64
62
|
|
@@ -70,7 +68,7 @@ describe Kitchen::StateFile do
|
|
70
68
|
|
71
69
|
state_file.read.class.wont_equal YamledState
|
72
70
|
state_file.read.class.must_equal Hash
|
73
|
-
state_file.read.must_equal(:
|
71
|
+
state_file.read.must_equal(yoinks: "zoinks")
|
74
72
|
end
|
75
73
|
|
76
74
|
it "raises a StateFileLoadError if the state file cannot be parsed" do
|
@@ -78,11 +76,9 @@ describe Kitchen::StateFile do
|
|
78
76
|
|
79
77
|
proc { state_file.read }.must_raise Kitchen::StateFileLoadError
|
80
78
|
end
|
81
|
-
|
82
79
|
end
|
83
80
|
|
84
81
|
describe "#write" do
|
85
|
-
|
86
82
|
it "creates the directory path to the state file" do
|
87
83
|
File.directory?("/tmp/.kitchen").must_equal false
|
88
84
|
state_file.write({})
|
@@ -90,14 +86,13 @@ describe Kitchen::StateFile do
|
|
90
86
|
end
|
91
87
|
|
92
88
|
it "writes a state file with stringified keys" do
|
93
|
-
state_file.write(:
|
89
|
+
state_file.write(thekey: "thyself")
|
94
90
|
|
95
91
|
IO.read(file_name).split("\n").must_include "thekey: thyself"
|
96
92
|
end
|
97
93
|
end
|
98
94
|
|
99
95
|
describe "#destroy" do
|
100
|
-
|
101
96
|
it "executes if no file exists" do
|
102
97
|
File.exist?(file_name).must_equal false
|
103
98
|
state_file.destroy
|
data/spec/kitchen/suite_spec.rb
CHANGED
@@ -22,12 +22,11 @@ require "kitchen/errors"
|
|
22
22
|
require "kitchen/suite"
|
23
23
|
|
24
24
|
describe Kitchen::Suite do
|
25
|
-
|
26
25
|
let(:opts) do
|
27
26
|
{
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
27
|
+
name: "suitezy",
|
28
|
+
includes: %w{testbuntu testcent},
|
29
|
+
excludes: %w{prodbuntu},
|
31
30
|
}
|
32
31
|
end
|
33
32
|
|
@@ -43,7 +42,7 @@ describe Kitchen::Suite do
|
|
43
42
|
end
|
44
43
|
|
45
44
|
it "returns the includes" do
|
46
|
-
suite.includes.must_equal %w
|
45
|
+
suite.includes.must_equal %w{testbuntu testcent}
|
47
46
|
end
|
48
47
|
|
49
48
|
it "returns an empty Array when includes not given" do
|
@@ -52,7 +51,7 @@ describe Kitchen::Suite do
|
|
52
51
|
end
|
53
52
|
|
54
53
|
it "returns the excludes" do
|
55
|
-
suite.excludes.must_equal %w
|
54
|
+
suite.excludes.must_equal %w{prodbuntu}
|
56
55
|
end
|
57
56
|
|
58
57
|
it "returns an empty Array when excludes not given" do
|