ztk 3.0.3 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -10
- data/README.md +1 -1
- data/lib/ztk/version.rb +1 -1
- data/spec/support/before_install.sh +1 -2
- data/spec/ztk/ansi_spec.rb +83 -0
- data/spec/ztk/ssh_spec.rb +167 -38
- data/spec/ztk/tcp_socket_check_spec.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdc8f617cd4946e08ae511019c8c824602e10690
|
4
|
+
data.tar.gz: d59c97edbd63a148a7453aa5ccfc5ade274928b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2ba6a6764ad01b16e5e7dfd33e704f34b7c33c666299745622035c8eeefc0fc0c71d9bacb18f4587e24de74c5688a6a6a20d8b3fe4dc5e966a54dc8d4be3292
|
7
|
+
data.tar.gz: 6f715ee4bb05e8cc3430756556834f6057d0cd9e4d7525a054836c2240d0b2f3f8c355dbb9b6fd41df81d61b3b7ed9515eca9708237ed49017dd0de782327a1c
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
# ZTK
|
8
8
|
|
9
|
-
Zachary's Tool Kit contains a collection of reusable classes meant to simplify development of complex systems in Ruby
|
9
|
+
Zachary's Tool Kit contains a collection of reusable classes meant to simplify development of complex systems in Ruby. These classes provide functionality I often find myself needing from project to project. Instead of reinventing the wheel each time, I've started building a collection of reusable classes. Easy-bake DSLs, parallel processing, complex logging, templating and many other useful design patterns, for example are all contained in simple, reusable classes with a common interface and configuration style.
|
10
10
|
|
11
11
|
- **ZTK::ANSI**
|
12
12
|
|
data/lib/ztk/version.rb
CHANGED
@@ -0,0 +1,83 @@
|
|
1
|
+
################################################################################
|
2
|
+
#
|
3
|
+
# Author: Zachary Patten <zachary AT jovelabs DOT com>
|
4
|
+
# Copyright: Copyright (c) Zachary Patten
|
5
|
+
# License: Apache License, Version 2.0
|
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
|
+
################################################################################
|
20
|
+
|
21
|
+
require "spec_helper"
|
22
|
+
|
23
|
+
describe "ZTK::ANSI Module" do
|
24
|
+
|
25
|
+
subject { ZTK::ANSI }
|
26
|
+
|
27
|
+
describe "module" do
|
28
|
+
|
29
|
+
it "should be ZTK::ANSI" do
|
30
|
+
subject.should be ZTK::ANSI
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "ZTK::ANSI Monkey-Patch String Class" do
|
38
|
+
|
39
|
+
subject {
|
40
|
+
class String
|
41
|
+
include ZTK::ANSI
|
42
|
+
end
|
43
|
+
}
|
44
|
+
|
45
|
+
describe "class" do
|
46
|
+
|
47
|
+
it "should include ZTK::ANSI" do
|
48
|
+
expect(subject.include?(ZTK::ANSI)).to be true
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "methods" do
|
54
|
+
|
55
|
+
ZTK::ANSI::ANSI_COLORS.each do |color, code|
|
56
|
+
|
57
|
+
it "should color the string #{color}" do
|
58
|
+
expect(subject.new("#{color}").send(color)).to match(/#{color}/)
|
59
|
+
expect(subject.new("#{color}").send(color)).to match(/#{code}/)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should remove #{color} color from the string" do
|
63
|
+
expect(subject.new("#{color}").send(color).uncolor).to match(/#{color}/)
|
64
|
+
expect(subject.new("#{color}").send(color).uncolor).not_to match(/#{code}/)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
it "should reset the screen and color the string #{color}" do
|
69
|
+
expect(subject.new("#{color}").send(color).reset).to match(/#{color}/)
|
70
|
+
expect(subject.new("#{color}").send(color).reset).to match(/#{code}/)
|
71
|
+
expect(subject.new("#{color}").send(color).reset).to start_with("\e[2J")
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
x, y = Random.rand(25), Random.rand(25)
|
77
|
+
it "should move the cursor to #{x},#{y}" do
|
78
|
+
expect(subject.new.goto(x,y)).to start_with("\e[#{x};#{y}H")
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/spec/ztk/ssh_spec.rb
CHANGED
@@ -35,7 +35,7 @@ describe ZTK::SSH do
|
|
35
35
|
describe "class" do
|
36
36
|
|
37
37
|
it "should be an instance of ZTK::SSH" do
|
38
|
-
subject.
|
38
|
+
expect(subject).to be_an_instance_of ZTK::SSH
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
@@ -59,6 +59,8 @@ describe ZTK::SSH do
|
|
59
59
|
status.exit_code.should == 0
|
60
60
|
@ui.stdout.rewind
|
61
61
|
@ui.stdout.read.chomp.should == data
|
62
|
+
|
63
|
+
expect(subject.close).to be true
|
62
64
|
end
|
63
65
|
|
64
66
|
it "should timeout after the period specified" do
|
@@ -71,6 +73,8 @@ describe ZTK::SSH do
|
|
71
73
|
end
|
72
74
|
hostname = %x(hostname).chomp
|
73
75
|
lambda { subject.exec("hostname ; sleep 10") }.should raise_error ZTK::SSHError
|
76
|
+
|
77
|
+
expect(subject.close).to be true
|
74
78
|
end
|
75
79
|
|
76
80
|
it "should throw an exception if the exit status is not as expected" do
|
@@ -81,6 +85,8 @@ describe ZTK::SSH do
|
|
81
85
|
config.host_name = "127.0.0.1"
|
82
86
|
end
|
83
87
|
lambda { subject.exec("/bin/bash -c 'exit 64'") }.should raise_error ZTK::SSHError
|
88
|
+
|
89
|
+
expect(subject.close).to be true
|
84
90
|
end
|
85
91
|
|
86
92
|
it "should return a instance of an OpenStruct object" do
|
@@ -92,6 +98,8 @@ describe ZTK::SSH do
|
|
92
98
|
end
|
93
99
|
result = subject.exec(%q{echo "Hello World"})
|
94
100
|
result.should be_an_instance_of OpenStruct
|
101
|
+
|
102
|
+
expect(subject.close).to be true
|
95
103
|
end
|
96
104
|
|
97
105
|
it "should return the exit code" do
|
@@ -105,6 +113,8 @@ describe ZTK::SSH do
|
|
105
113
|
|
106
114
|
result = subject.exec(%Q{/bin/bash -c 'exit #{data}'}, :exit_code => data)
|
107
115
|
result.exit_code.should == data
|
116
|
+
|
117
|
+
expect(subject.close).to be true
|
108
118
|
end
|
109
119
|
|
110
120
|
it "should return the output" do
|
@@ -118,6 +128,8 @@ describe ZTK::SSH do
|
|
118
128
|
|
119
129
|
result = subject.exec(%Q{echo "#{data}"})
|
120
130
|
result.output.match(data).should_not be nil
|
131
|
+
|
132
|
+
expect(subject.close).to be true
|
121
133
|
end
|
122
134
|
|
123
135
|
it "should allow us to change the expected exit code" do
|
@@ -129,6 +141,47 @@ describe ZTK::SSH do
|
|
129
141
|
end
|
130
142
|
data = 32
|
131
143
|
result = subject.exec(%Q{/bin/bash -c 'exit #{data}'}, :exit_code => data)
|
144
|
+
|
145
|
+
expect(subject.close).to be true
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should allow us to execute a bootstrap script" do
|
149
|
+
subject.config do |config|
|
150
|
+
config.ui = @ui
|
151
|
+
|
152
|
+
config.user = ENV["USER"]
|
153
|
+
config.host_name = "127.0.0.1"
|
154
|
+
end
|
155
|
+
data = "Hello World @ #{Time.now.utc}"
|
156
|
+
|
157
|
+
result = subject.bootstrap(<<-EOBOOTSTRAP)
|
158
|
+
echo "#{data}" >&1
|
159
|
+
EOBOOTSTRAP
|
160
|
+
|
161
|
+
expect(result.output).to match(/#{data}/)
|
162
|
+
|
163
|
+
expect(subject.close).to be true
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should allow us to write a file" do
|
167
|
+
subject.config do |config|
|
168
|
+
config.ui = @ui
|
169
|
+
|
170
|
+
config.user = ENV["USER"]
|
171
|
+
config.host_name = "127.0.0.1"
|
172
|
+
end
|
173
|
+
data = "Hello World @ #{Time.now.utc}"
|
174
|
+
test_filename = File.join("", "tmp", "test_file.txt")
|
175
|
+
|
176
|
+
subject.file(:target => test_filename) do |f|
|
177
|
+
f.write(data)
|
178
|
+
end
|
179
|
+
|
180
|
+
result = subject.exec(%Q{cat #{test_filename}})
|
181
|
+
|
182
|
+
expect(result.output).to match(/#{data}/)
|
183
|
+
|
184
|
+
expect(subject.close).to be true
|
132
185
|
end
|
133
186
|
|
134
187
|
describe "stdout" do
|
@@ -142,16 +195,18 @@ describe ZTK::SSH do
|
|
142
195
|
end
|
143
196
|
data = "Hello World @ #{Time.now.utc}"
|
144
197
|
|
145
|
-
subject.exec(%Q{echo "#{data}"
|
198
|
+
subject.exec(%Q{echo "#{data}" >&1})
|
146
199
|
|
147
200
|
@ui.stdout.rewind
|
148
|
-
@ui.stdout.read.match(data)
|
201
|
+
expect(@ui.stdout.read).to match(/#{data}/)
|
149
202
|
|
150
203
|
@ui.stderr.rewind
|
151
|
-
@ui.stderr.read
|
204
|
+
expect(@ui.stderr.read).to be_empty
|
152
205
|
|
153
206
|
@ui.stdin.rewind
|
154
|
-
@ui.stdin.read
|
207
|
+
expect(@ui.stdin.read).to be_empty
|
208
|
+
|
209
|
+
expect(subject.close).to be true
|
155
210
|
end
|
156
211
|
|
157
212
|
it "should capture STDOUT (without PTY) and send it to the STDOUT pipe" do
|
@@ -165,16 +220,18 @@ describe ZTK::SSH do
|
|
165
220
|
end
|
166
221
|
data = "Hello World @ #{Time.now.utc}"
|
167
222
|
|
168
|
-
subject.exec(%Q{echo "#{data}"
|
223
|
+
subject.exec(%Q{echo "#{data}" >&1})
|
169
224
|
|
170
225
|
@ui.stdout.rewind
|
171
|
-
@ui.stdout.read.match(data)
|
226
|
+
expect(@ui.stdout.read).to match(/#{data}/)
|
172
227
|
|
173
228
|
@ui.stderr.rewind
|
174
|
-
@ui.stderr.read
|
229
|
+
expect(@ui.stderr.read).to be_empty
|
175
230
|
|
176
231
|
@ui.stdin.rewind
|
177
|
-
@ui.stdin.read
|
232
|
+
expect(@ui.stdin.read).to be_empty
|
233
|
+
|
234
|
+
expect(subject.close).to be true
|
178
235
|
end
|
179
236
|
|
180
237
|
end
|
@@ -190,16 +247,18 @@ describe ZTK::SSH do
|
|
190
247
|
end
|
191
248
|
data = "Hello World @ #{Time.now.utc}"
|
192
249
|
|
193
|
-
subject.exec(%Q{echo "#{data}"
|
250
|
+
subject.exec(%Q{echo "#{data}" >&2})
|
194
251
|
|
195
252
|
@ui.stdout.rewind
|
196
|
-
@ui.stdout.read.match(data)
|
253
|
+
expect(@ui.stdout.read).to match(/#{data}/)
|
197
254
|
|
198
255
|
@ui.stderr.rewind
|
199
|
-
@ui.stderr.read
|
256
|
+
expect(@ui.stderr.read).to be_empty
|
200
257
|
|
201
258
|
@ui.stdin.rewind
|
202
|
-
@ui.stdin.read
|
259
|
+
expect(@ui.stdin.read).to be_empty
|
260
|
+
|
261
|
+
expect(subject.close).to be true
|
203
262
|
end
|
204
263
|
|
205
264
|
it "should capture STDERR (without PTY) and send it to the STDERR pipe" do
|
@@ -213,16 +272,18 @@ describe ZTK::SSH do
|
|
213
272
|
end
|
214
273
|
data = "Hello World @ #{Time.now.utc}"
|
215
274
|
|
216
|
-
subject.exec(%Q{echo "#{data}"
|
275
|
+
subject.exec(%Q{echo "#{data}" >&2})
|
217
276
|
|
218
277
|
@ui.stdout.rewind
|
219
|
-
@ui.stdout.read
|
278
|
+
expect(@ui.stdout.read).to be_empty
|
220
279
|
|
221
280
|
@ui.stderr.rewind
|
222
|
-
@ui.stderr.read.match(data)
|
281
|
+
expect(@ui.stderr.read).to match(/#{data}/)
|
223
282
|
|
224
283
|
@ui.stdin.rewind
|
225
|
-
@ui.stdin.read
|
284
|
+
expect(@ui.stdin.read).to be_empty
|
285
|
+
|
286
|
+
expect(subject.close).to be true
|
226
287
|
end
|
227
288
|
|
228
289
|
end
|
@@ -259,11 +320,13 @@ describe ZTK::SSH do
|
|
259
320
|
end
|
260
321
|
|
261
322
|
File.exists?(remote_file).should == false
|
262
|
-
subject.upload(local_file, remote_file)
|
323
|
+
subject.upload(local_file, remote_file, :use_scp => use_scp)
|
263
324
|
File.exists?(remote_file).should == true
|
264
325
|
|
265
326
|
File.exists?(remote_file) && File.delete(remote_file)
|
266
327
|
File.exists?(local_file) && File.delete(local_file)
|
328
|
+
|
329
|
+
expect(subject.close).to be true
|
267
330
|
end
|
268
331
|
end
|
269
332
|
|
@@ -278,7 +341,6 @@ describe ZTK::SSH do
|
|
278
341
|
|
279
342
|
config.user = ENV["USER"]
|
280
343
|
config.host_name = "127.0.0.1"
|
281
|
-
config.use_scp = use_scp
|
282
344
|
end
|
283
345
|
|
284
346
|
data = "Hello World @ #{Time.now.utc}"
|
@@ -300,11 +362,13 @@ describe ZTK::SSH do
|
|
300
362
|
end
|
301
363
|
|
302
364
|
File.exists?(local_file).should == false
|
303
|
-
subject.download(remote_file, local_file)
|
365
|
+
subject.download(remote_file, local_file, :use_scp => use_scp)
|
304
366
|
File.exists?(local_file).should == true
|
305
367
|
|
306
368
|
File.exists?(local_file) && File.delete(local_file)
|
307
369
|
File.exists?(remote_file) && File.delete(remote_file)
|
370
|
+
|
371
|
+
expect(subject.close).to be true
|
308
372
|
end
|
309
373
|
end
|
310
374
|
|
@@ -332,6 +396,8 @@ describe ZTK::SSH do
|
|
332
396
|
status.exit_code.should == 0
|
333
397
|
@ui.stdout.rewind
|
334
398
|
@ui.stdout.read.chomp.should == data
|
399
|
+
|
400
|
+
expect(subject.close).to be true
|
335
401
|
end
|
336
402
|
|
337
403
|
it "should timeout after the period specified" do
|
@@ -346,6 +412,8 @@ describe ZTK::SSH do
|
|
346
412
|
end
|
347
413
|
hostname = %x(hostname).chomp
|
348
414
|
lambda { subject.exec("hostname ; sleep 10") }.should raise_error ZTK::SSHError
|
415
|
+
|
416
|
+
expect(subject.close).to be true
|
349
417
|
end
|
350
418
|
|
351
419
|
it "should throw an exception if the exit status is not as expected" do
|
@@ -358,6 +426,8 @@ describe ZTK::SSH do
|
|
358
426
|
config.proxy_host_name = "127.0.0.1"
|
359
427
|
end
|
360
428
|
lambda { subject.exec("/bin/bash -c 'exit 64'") }.should raise_error ZTK::SSHError
|
429
|
+
|
430
|
+
expect(subject.close).to be true
|
361
431
|
end
|
362
432
|
|
363
433
|
it "should return a instance of an OpenStruct object" do
|
@@ -371,6 +441,8 @@ describe ZTK::SSH do
|
|
371
441
|
end
|
372
442
|
result = subject.exec(%q{echo "Hello World"})
|
373
443
|
result.should be_an_instance_of OpenStruct
|
444
|
+
|
445
|
+
expect(subject.close).to be true
|
374
446
|
end
|
375
447
|
|
376
448
|
it "should return the exit code" do
|
@@ -386,6 +458,8 @@ describe ZTK::SSH do
|
|
386
458
|
|
387
459
|
result = subject.exec(%Q{/bin/bash -c 'exit #{data}'}, :exit_code => data)
|
388
460
|
result.exit_code.should == data
|
461
|
+
|
462
|
+
expect(subject.close).to be true
|
389
463
|
end
|
390
464
|
|
391
465
|
it "should return the output" do
|
@@ -401,6 +475,8 @@ describe ZTK::SSH do
|
|
401
475
|
|
402
476
|
result = subject.exec(%Q{echo "#{data}"})
|
403
477
|
result.output.match(data).should_not be nil
|
478
|
+
|
479
|
+
expect(subject.close).to be true
|
404
480
|
end
|
405
481
|
|
406
482
|
it "should allow us to change the expected exit code" do
|
@@ -414,6 +490,47 @@ describe ZTK::SSH do
|
|
414
490
|
end
|
415
491
|
data = 32
|
416
492
|
result = subject.exec(%Q{/bin/bash -c 'exit #{data}'}, :exit_code => data)
|
493
|
+
|
494
|
+
expect(subject.close).to be true
|
495
|
+
end
|
496
|
+
|
497
|
+
it "should allow us to execute a bootstrap script" do
|
498
|
+
subject.config do |config|
|
499
|
+
config.ui = @ui
|
500
|
+
|
501
|
+
config.user = ENV["USER"]
|
502
|
+
config.host_name = "127.0.0.1"
|
503
|
+
end
|
504
|
+
data = "Hello World @ #{Time.now.utc}"
|
505
|
+
|
506
|
+
result = subject.bootstrap(<<-EOBOOTSTRAP)
|
507
|
+
echo "#{data}" >&1
|
508
|
+
EOBOOTSTRAP
|
509
|
+
|
510
|
+
expect(result.output).to match(/#{data}/)
|
511
|
+
|
512
|
+
expect(subject.close).to be true
|
513
|
+
end
|
514
|
+
|
515
|
+
it "should allow us to write a file" do
|
516
|
+
subject.config do |config|
|
517
|
+
config.ui = @ui
|
518
|
+
|
519
|
+
config.user = ENV["USER"]
|
520
|
+
config.host_name = "127.0.0.1"
|
521
|
+
end
|
522
|
+
data = "Hello World @ #{Time.now.utc}"
|
523
|
+
test_filename = File.join("", "tmp", "test_file.txt")
|
524
|
+
|
525
|
+
subject.file(:target => test_filename) do |f|
|
526
|
+
f.write(data)
|
527
|
+
end
|
528
|
+
|
529
|
+
result = subject.exec(%Q{cat #{test_filename}})
|
530
|
+
|
531
|
+
expect(result.output).to match(/#{data}/)
|
532
|
+
|
533
|
+
expect(subject.close).to be true
|
417
534
|
end
|
418
535
|
|
419
536
|
describe "stdout" do
|
@@ -429,16 +546,18 @@ describe ZTK::SSH do
|
|
429
546
|
end
|
430
547
|
data = "Hello World @ #{Time.now.utc}"
|
431
548
|
|
432
|
-
subject.exec(%Q{echo "#{data}"
|
549
|
+
subject.exec(%Q{echo "#{data}" >&1})
|
433
550
|
|
434
551
|
@ui.stdout.rewind
|
435
|
-
@ui.stdout.read.match(data)
|
552
|
+
expect(@ui.stdout.read).to match(/#{data}/)
|
436
553
|
|
437
554
|
@ui.stderr.rewind
|
438
|
-
@ui.stderr.read
|
555
|
+
expect(@ui.stderr.read).to be_empty
|
439
556
|
|
440
557
|
@ui.stdin.rewind
|
441
|
-
@ui.stdin.read
|
558
|
+
expect(@ui.stdin.read).to be_empty
|
559
|
+
|
560
|
+
expect(subject.close).to be true
|
442
561
|
end
|
443
562
|
|
444
563
|
it "should capture STDOUT (without PTY) and send it to the STDOUT pipe" do
|
@@ -454,16 +573,18 @@ describe ZTK::SSH do
|
|
454
573
|
end
|
455
574
|
data = "Hello World @ #{Time.now.utc}"
|
456
575
|
|
457
|
-
subject.exec(%Q{echo "#{data}"
|
576
|
+
subject.exec(%Q{echo "#{data}" >&1})
|
458
577
|
|
459
578
|
@ui.stdout.rewind
|
460
|
-
@ui.stdout.read.match(data)
|
579
|
+
expect(@ui.stdout.read).to match(/#{data}/)
|
461
580
|
|
462
581
|
@ui.stderr.rewind
|
463
|
-
@ui.stderr.read
|
582
|
+
expect(@ui.stderr.read).to be_empty
|
464
583
|
|
465
584
|
@ui.stdin.rewind
|
466
|
-
@ui.stdin.read
|
585
|
+
expect(@ui.stdin.read).to be_empty
|
586
|
+
|
587
|
+
expect(subject.close).to be true
|
467
588
|
end
|
468
589
|
|
469
590
|
end
|
@@ -481,16 +602,18 @@ describe ZTK::SSH do
|
|
481
602
|
end
|
482
603
|
data = "Hello World @ #{Time.now.utc}"
|
483
604
|
|
484
|
-
subject.exec(%Q{echo "#{data}"
|
605
|
+
subject.exec(%Q{echo "#{data}" >&2})
|
485
606
|
|
486
607
|
@ui.stdout.rewind
|
487
|
-
@ui.stdout.read.match(data)
|
608
|
+
expect(@ui.stdout.read).to match(/#{data}/)
|
488
609
|
|
489
610
|
@ui.stderr.rewind
|
490
|
-
@ui.stderr.read
|
611
|
+
expect(@ui.stderr.read).to be_empty
|
491
612
|
|
492
613
|
@ui.stdin.rewind
|
493
|
-
@ui.stdin.read
|
614
|
+
expect(@ui.stdin.read).to be_empty
|
615
|
+
|
616
|
+
expect(subject.close).to be true
|
494
617
|
end
|
495
618
|
|
496
619
|
it "should capture STDERR (without PTY) and send it to the STDERR pipe" do
|
@@ -506,16 +629,18 @@ describe ZTK::SSH do
|
|
506
629
|
end
|
507
630
|
data = "Hello World @ #{Time.now.utc}"
|
508
631
|
|
509
|
-
subject.exec(%Q{echo "#{data}"
|
632
|
+
subject.exec(%Q{echo "#{data}" >&2})
|
510
633
|
|
511
634
|
@ui.stdout.rewind
|
512
|
-
@ui.stdout.read
|
635
|
+
expect(@ui.stdout.read).to be_empty
|
513
636
|
|
514
637
|
@ui.stderr.rewind
|
515
|
-
@ui.stderr.read.match(data)
|
638
|
+
expect(@ui.stderr.read).to match(/#{data}/)
|
516
639
|
|
517
640
|
@ui.stdin.rewind
|
518
|
-
@ui.stdin.read
|
641
|
+
expect(@ui.stdin.read).to be_empty
|
642
|
+
|
643
|
+
expect(subject.close).to be true
|
519
644
|
end
|
520
645
|
|
521
646
|
end
|
@@ -554,11 +679,13 @@ describe ZTK::SSH do
|
|
554
679
|
end
|
555
680
|
|
556
681
|
File.exists?(remote_file).should == false
|
557
|
-
subject.upload(local_file, remote_file)
|
682
|
+
subject.upload(local_file, remote_file, :use_scp => use_scp)
|
558
683
|
File.exists?(remote_file).should == true
|
559
684
|
|
560
685
|
File.exists?(remote_file) && File.delete(remote_file)
|
561
686
|
File.exists?(local_file) && File.delete(local_file)
|
687
|
+
|
688
|
+
expect(subject.close).to be true
|
562
689
|
end
|
563
690
|
end
|
564
691
|
|
@@ -596,11 +723,13 @@ describe ZTK::SSH do
|
|
596
723
|
end
|
597
724
|
|
598
725
|
File.exists?(local_file).should == false
|
599
|
-
subject.download(remote_file, local_file)
|
726
|
+
subject.download(remote_file, local_file, :use_scp => use_scp)
|
600
727
|
File.exists?(local_file).should == true
|
601
728
|
|
602
729
|
File.exists?(local_file) && File.delete(local_file)
|
603
730
|
File.exists?(remote_file) && File.delete(remote_file)
|
731
|
+
|
732
|
+
expect(subject.close).to be true
|
604
733
|
end
|
605
734
|
end
|
606
735
|
|
@@ -98,10 +98,10 @@ describe ZTK::TCPSocketCheck do
|
|
98
98
|
|
99
99
|
describe "read check" do
|
100
100
|
|
101
|
-
it "should return false on a read check to 127.0.0.1:
|
101
|
+
it "should return false on a read check to 127.0.0.1:1" do
|
102
102
|
subject.config do |config|
|
103
103
|
config.host = "127.0.0.1"
|
104
|
-
config.port =
|
104
|
+
config.port = 1
|
105
105
|
config.wait = WAIT_SMALL
|
106
106
|
end
|
107
107
|
subject.wait.should == false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Patten
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -346,6 +346,7 @@ files:
|
|
346
346
|
- spec/support/before_install.sh
|
347
347
|
- spec/support/test-config.rb
|
348
348
|
- spec/support/test-template.txt.erb
|
349
|
+
- spec/ztk/ansi_spec.rb
|
349
350
|
- spec/ztk/background_spec.rb
|
350
351
|
- spec/ztk/base_spec.rb
|
351
352
|
- spec/ztk/benchmark_spec.rb
|
@@ -394,6 +395,7 @@ test_files:
|
|
394
395
|
- spec/support/before_install.sh
|
395
396
|
- spec/support/test-config.rb
|
396
397
|
- spec/support/test-template.txt.erb
|
398
|
+
- spec/ztk/ansi_spec.rb
|
397
399
|
- spec/ztk/background_spec.rb
|
398
400
|
- spec/ztk/base_spec.rb
|
399
401
|
- spec/ztk/benchmark_spec.rb
|