unix_utils 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/lib/unix_utils.rb +1 -1
- data/lib/unix_utils/version.rb +1 -1
- data/test/test_unix_utils.rb +21 -3
- metadata +1 -1
data/History.txt
CHANGED
data/lib/unix_utils.rb
CHANGED
data/lib/unix_utils/version.rb
CHANGED
data/test/test_unix_utils.rb
CHANGED
@@ -282,8 +282,8 @@ describe UnixUtils do
|
|
282
282
|
describe :wc do
|
283
283
|
before do
|
284
284
|
@f = Tempfile.new('wc.txt')
|
285
|
-
@f.write "dos line\r\n"*
|
286
|
-
@f.write "unix line\n"*
|
285
|
+
@f.write "dos line\r\n"*50_000
|
286
|
+
@f.write "unix line\n"*50_000
|
287
287
|
@f.flush
|
288
288
|
@infile = @f.path
|
289
289
|
end
|
@@ -291,7 +291,7 @@ describe UnixUtils do
|
|
291
291
|
@f.close
|
292
292
|
end
|
293
293
|
it 'counts lines, words, and bytes' do
|
294
|
-
UnixUtils.wc(@infile).must_equal [
|
294
|
+
UnixUtils.wc(@infile).must_equal [50_000+50_000, 100_000+100_000, 500_000+500_000]
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
@@ -419,4 +419,22 @@ describe UnixUtils do
|
|
419
419
|
UnixUtils.tmp_path("dirname1/dirname2/basename.extname").wont_include 'dirname1'
|
420
420
|
end
|
421
421
|
end
|
422
|
+
|
423
|
+
# not really for public consumption
|
424
|
+
describe :spawn do
|
425
|
+
before do
|
426
|
+
@f = Tempfile.new('spawn.txt')
|
427
|
+
@f.write "dos line\r\n"*50_000
|
428
|
+
@f.write "unix line\n"*50_000
|
429
|
+
@f.flush
|
430
|
+
@infile = @f.path
|
431
|
+
end
|
432
|
+
after do
|
433
|
+
@f.close
|
434
|
+
end
|
435
|
+
it 'reads and writes everything' do
|
436
|
+
wc_output = UnixUtils.spawn(['wc'], :read_from => @infile)
|
437
|
+
wc_output.strip.split(/\s+/)[0..2].map { |s| s.to_i }.must_equal [50_000+50_000, 100_000+100_000, 500_000+500_000]
|
438
|
+
end
|
439
|
+
end
|
422
440
|
end
|