ndr_support 5.10.4 → 5.10.5

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +3 -3
  5. data/lib/ndr_support/concerns/working_days.rb +12 -1
  6. data/lib/ndr_support/string/clean_methodable.rb +4 -4
  7. data/lib/ndr_support/version.rb +1 -1
  8. data/ndr_support.gemspec +8 -6
  9. metadata +10 -73
  10. data/.gitignore +0 -19
  11. data/.rubocop.yml +0 -1
  12. data/Gemfile +0 -4
  13. data/Guardfile +0 -24
  14. data/Rakefile +0 -12
  15. data/code_safety.yml +0 -294
  16. data/gemfiles/Gemfile.rails70 +0 -6
  17. data/gemfiles/Gemfile.rails71 +0 -6
  18. data/gemfiles/Gemfile.rails72 +0 -6
  19. data/gemfiles/Gemfile.rails80 +0 -6
  20. data/test/array_test.rb +0 -20
  21. data/test/concerns/working_days_test.rb +0 -148
  22. data/test/date_and_time_extensions_test.rb +0 -82
  23. data/test/daterange_test.rb +0 -303
  24. data/test/hash_test.rb +0 -84
  25. data/test/integer/calculations_test.rb +0 -28
  26. data/test/integer/rounding_test.rb +0 -14
  27. data/test/integer/working_days_test.rb +0 -14
  28. data/test/nil_test.rb +0 -40
  29. data/test/obfuscator_test.rb +0 -26
  30. data/test/ourdate_test.rb +0 -26
  31. data/test/ourtime_test.rb +0 -45
  32. data/test/password_test.rb +0 -129
  33. data/test/regexp_range_test.rb +0 -136
  34. data/test/resources/filesystem_paths.yml +0 -37
  35. data/test/safe_file_test.rb +0 -670
  36. data/test/safe_path_test.rb +0 -168
  37. data/test/string/cleaning_test.rb +0 -247
  38. data/test/string/conversions_test.rb +0 -371
  39. data/test/test_helper.rb +0 -42
  40. data/test/threat_scanner_test.rb +0 -77
  41. data/test/utf8_encoding/control_characters_test.rb +0 -84
  42. data/test/utf8_encoding/force_binary_test.rb +0 -64
  43. data/test/utf8_encoding_test.rb +0 -170
  44. data/test/yaml/serialization_test.rb +0 -200
@@ -1,670 +0,0 @@
1
- require 'test_helper'
2
-
3
- # Switch on the patientlimiter as though in external environment
4
-
5
- class SafeFileTest < Minitest::Test
6
- def setup
7
- @not_empty_fpath = SafePath.new('test_space_rw').join('test_file_rw_not_empty')
8
-
9
- File.open(@not_empty_fpath, 'w') do |f|
10
- f.write 'I am not empty'
11
- end
12
-
13
- @empty_fpath = SafePath.new('test_space_rw').join('test_file_rw')
14
-
15
- File.open(@empty_fpath, 'w') do |f|
16
- f.write ''
17
- end
18
- end
19
-
20
- def teardown
21
- FileUtils.rm(Dir[SafePath.new('test_space_rw').join('*')])
22
- end
23
-
24
- ################################################################################
25
- # .new
26
-
27
- test 'constructor should accept safe_path only' do
28
- assert_raises(ArgumentError) { SafeFile.new }
29
- assert_raises(ArgumentError) { SafeFile.new('example_file', 'rw') }
30
- end
31
-
32
- test 'constructor should only allow string or numeric second argument' do
33
- assert_raises(ArgumentError) { SafeFile.new(@not_empty_fpath, {}) }
34
- end
35
-
36
- test 'should raise exception if try to write in read-only space' do
37
- assert_raises SecurityError do
38
- SafeFile.new(SafePath.new('test_space_r').join!('test_file_r'), 'a+')
39
- end
40
-
41
- assert_raises SecurityError do
42
- SafeFile.new(SafePath.new('test_space_r').join!('test_file_r'), 'a')
43
- end
44
-
45
- assert_raises SecurityError do
46
- SafeFile.new(SafePath.new('test_space_r').join!('test_file_r'), 'r+')
47
- end
48
-
49
- assert_raises SecurityError do
50
- SafeFile.new(SafePath.new('test_space_r').join!('test_file_r'), 'w')
51
- end
52
- end
53
-
54
- test 'should raise exception if try to read in write only space' do
55
- assert_raises SecurityError do
56
- SafeFile.new(SafePath.new('test_space_w').join!('test_file_w'), 'a+')
57
- end
58
-
59
- assert_raises SecurityError do
60
- SafeFile.new(SafePath.new('test_space_w').join!('test_file_w'), 'r+')
61
- end
62
-
63
- assert_raises SecurityError do
64
- SafeFile.new(SafePath.new('test_space_w').join!('test_file_w'), 'r')
65
- end
66
- end
67
-
68
- test 'should read from read-only space and write to write only space' do
69
- write_only_path = SafePath.new('test_space_w').join!('new_file_rw_new_file')
70
- read_only_path = SafePath.new('test_space_r').join!('new_file_rw_new_file')
71
- refute File.exist?(read_only_path)
72
-
73
- f = SafeFile.new(write_only_path, 'w')
74
- assert_equal 4, f.write('test')
75
- f.close
76
-
77
- assert File.exist?(read_only_path)
78
-
79
- f = SafeFile.new(read_only_path, 'r')
80
- assert_equal 'test', f.read
81
- f.close
82
- end
83
-
84
- test 'should read/write from file with new to rw space' do
85
- fpath = SafePath.new('test_space_rw').join!('new_file_rw_new_file')
86
-
87
- refute File.exist?(fpath)
88
-
89
- f = SafeFile.new(fpath, 'w')
90
- assert_equal 4, f.write('test')
91
- f.close
92
-
93
- assert File.exist?(fpath)
94
-
95
- f = SafeFile.new(fpath, 'r')
96
- assert_equal 'test', f.read
97
- f.close
98
- end
99
-
100
- test 'should accept mode types' do
101
- s = SafeFile.new(@empty_fpath, 'r')
102
- s.close
103
-
104
- s = SafeFile.new(@empty_fpath, 'w')
105
- s.close
106
-
107
- s = SafeFile.new(@empty_fpath, 'r+')
108
- s.close
109
-
110
- s = SafeFile.new(@empty_fpath, 'w+')
111
- s.close
112
-
113
- s = SafeFile.new(@empty_fpath, 'a+')
114
- s.close
115
-
116
- s = SafeFile.new(@empty_fpath, 'a')
117
- s.close
118
- end
119
-
120
- test 'should raise exception if incorect mode passed' do
121
- assert_raises ArgumentError do
122
- SafeFile.new(@empty_fpath, 'potato_mode')
123
- end
124
-
125
- assert_raises ArgumentError do
126
- SafeFile.new(@empty_fpath, 'rw+a+')
127
- end
128
-
129
- assert_raises ArgumentError do
130
- SafeFile.new(@empty_fpath, 'r+w+')
131
- end
132
- end
133
-
134
- test 'should accept permissions' do
135
- f = SafeFile.new(@empty_fpath, 'r', 755)
136
- f.close
137
-
138
- SafeFile.new(@empty_fpath, 755)
139
- end
140
-
141
- ################################################################################
142
- # ::open
143
-
144
- test '::open should accept safe_path only' do
145
- p = SafePath.new('test_space_rw').join('test1')
146
-
147
- refute File.exist?(p)
148
-
149
- assert_raises ArgumentError do
150
- SafeFile.open(p.to_s, 'r') do |f|
151
- f.write 'hohohoho'
152
- end
153
- end
154
-
155
- assert_raises ArgumentError do
156
- f = SafeFile.open(p.to_s, 'r')
157
- f.write 'hohohoho'
158
- f.close
159
- end
160
-
161
- refute File.exist?(p)
162
- end
163
-
164
- test '::open should check pathspace permissions' do
165
- read_only_path = SafePath.new('test_space_r').join!('new_file_rw_blablabla')
166
- write_only_path = SafePath.new('test_space_w').join!('test_file_rw_not_empty')
167
-
168
- refute File.exist?(read_only_path)
169
-
170
- assert_raises SecurityError do
171
- SafeFile.open(read_only_path, 'w') do |f|
172
- f.write('test')
173
- end
174
- end
175
-
176
- refute File.exist?(read_only_path)
177
-
178
- fcontent = 'something else'
179
-
180
- assert_raises SecurityError do
181
- SafeFile.open(write_only_path, 'r') do |f|
182
- fcontent = f.read
183
- end
184
- end
185
-
186
- refute_equal fcontent, File.read(write_only_path)
187
- end
188
-
189
- test '::open should read/write from file' do
190
- fpath = SafePath.new('test_space_rw').join!('new_file_rw_blablabla')
191
- read_only_path = SafePath.new('test_space_r').join!('new_file_rw_blablabla')
192
- write_only_path = SafePath.new('test_space_w').join!('new_file_rw_blablabla')
193
- refute File.exist?(fpath)
194
-
195
- SafeFile.open(fpath, 'w') do |f|
196
- assert_equal 4, f.write('test')
197
- end
198
-
199
- SafeFile.open(fpath, 'r') do |f|
200
- assert_equal 'test', f.read
201
- end
202
-
203
- # Test how the defailt arguments work
204
- SafeFile.open(read_only_path) do |f|
205
- assert_equal 'test', f.read
206
- end
207
-
208
- # Test how the defailt arguments work
209
- assert_raises SecurityError do
210
- SafeFile.open(write_only_path) do |f|
211
- assert_equal 'test', f.read
212
- end
213
- end
214
-
215
- assert_equal 1, File.delete(fpath)
216
- end
217
-
218
- test '::open should accept fs permissions with block' do
219
- p = SafePath.new('test_space_rw').join('test1')
220
-
221
- SafeFile.open(p, 'w', 255) do |f|
222
- f.write 'test332'
223
- end
224
-
225
- assert File.exist?(p)
226
- end
227
-
228
- test '::open should accept fs permissions with no block' do
229
- p = SafePath.new('test_space_rw').join('test1')
230
-
231
- f = SafeFile.open(p, 'w', 255)
232
- f.close
233
-
234
- assert File.exist?(p)
235
- end
236
-
237
- test '::open should work as new if no block passed' do
238
- p = SafePath.new('test_space_r').join('test_file_rw')
239
-
240
- f = SafeFile.open(p)
241
- assert_equal SafeFile, f.class
242
- f.close
243
- end
244
-
245
- ################################################################################
246
- # ::read
247
-
248
- test '::read should accept safe_path only' do
249
- assert_raises ArgumentError do
250
- SafeFile.read @not_empty_fpath.to_s
251
- end
252
- end
253
-
254
- test '::read should check pathspace permissions' do
255
- write_only_path = SafePath.new('test_space_w').join('test_file_rw')
256
-
257
- fcontent = 'none'
258
- assert_raises SecurityError do
259
- fcontent = SafeFile.read(write_only_path)
260
- end
261
- assert_equal 'none', fcontent
262
- end
263
-
264
- test '::read should read file content' do
265
- assert File.read(@not_empty_fpath), SafeFile.read(@not_empty_fpath)
266
- end
267
-
268
- ################################################################################
269
- # .read
270
-
271
- test '#read should check pathspace permissions' do
272
- p = SafePath.new('test_space_w').join('test_file_rw_not_empty')
273
-
274
- f = SafeFile.new(p, 'w')
275
- assert_raises SecurityError do
276
- f.read
277
- end
278
- f.close
279
- end
280
-
281
- test '#read should read read-only namespace' do
282
- p = SafePath.new('test_space_r').join('test_file_rw_not_empty')
283
-
284
- f = SafeFile.new(p, 'r')
285
- assert_equal 'I am not empty', f.read
286
- f.close
287
- end
288
-
289
- ################################################################################
290
- # .write
291
-
292
- test '#write should check pathspace permissions' do
293
- p = SafePath.new('test_space_r').join('test_file_rw_not_empty')
294
-
295
- f = SafeFile.new(p, 'r')
296
- assert_raises SecurityError do
297
- f.write 'junk'
298
- end
299
- f.close
300
- end
301
-
302
- test '#write should write to write namespace' do
303
- p = SafePath.new('test_space_rw').join('test1')
304
-
305
- f = SafeFile.new(p, 'w')
306
- f.write 'good test'
307
- f.close
308
-
309
- f = SafeFile.new(p, 'r')
310
- assert_equal 'good test', f.read
311
- f.close
312
-
313
- assert File.exist? p.to_s
314
- File.delete p
315
- end
316
-
317
- ################################################################################
318
- # .each / .each_line
319
-
320
- test '#each should check pathspace permissions when called with a block' do
321
- p = SafePath.new('test_space_w').join('test_file_rw_not_empty')
322
-
323
- f = SafeFile.new(p, 'w')
324
- assert_raises(SecurityError) { f.each { |line| line } }
325
- assert_raises(SecurityError) { f.each_line { |line| line } }
326
- f.close
327
- end
328
-
329
- test '#each should check pathspace permissions when called without a block' do
330
- p = SafePath.new('test_space_w').join('test_file_rw_not_empty')
331
-
332
- f = SafeFile.new(p, 'w')
333
- assert_raises(SecurityError) { f.each }
334
- assert_raises(SecurityError) { f.each_line }
335
- f.close
336
- end
337
-
338
- test '#each should return an enumerator in read-only namespace' do
339
- p = SafePath.new('test_space_r').join('test_file_rw_not_empty')
340
-
341
- f = SafeFile.new(p, 'r')
342
- assert f.each.is_a?(Enumerator)
343
- assert f.each_line.is_a?(Enumerator)
344
- f.close
345
- end
346
-
347
- test '#each should read lines from read-only namespace' do
348
- p = SafePath.new('test_space_r').join('test_file_rw_not_empty')
349
-
350
- f = SafeFile.new(p, 'r')
351
- assert_equal ['I am not empty'], f.each.to_a
352
- f.close
353
- end
354
-
355
- test '#each handles separator argument when in read-only namespace' do
356
- p = SafePath.new('test_space_r').join('test_file_rw_not_empty')
357
-
358
- f = SafeFile.new(p, 'r')
359
- assert_equal ['I am', ' not em', 'pty'], f.each('m').to_a
360
- f.close
361
- end
362
-
363
- test '#each handles limit argument when in read-only namespace' do
364
- p = SafePath.new('test_space_r').join('test_file_rw_not_empty')
365
-
366
- f = SafeFile.new(p, 'r')
367
- assert_equal ['I a', 'm n', 'ot ', 'emp', 'ty'], f.each(3).to_a
368
- f.close
369
- end
370
-
371
- test '#each handles separator and limit argument when in read-only namespace' do
372
- p = SafePath.new('test_space_r').join('test_file_rw_not_empty')
373
-
374
- f = SafeFile.new(p, 'r')
375
- assert_equal ['I am', ' not ', 'em', 'pty'], f.each('m', 5).to_a
376
- f.close
377
- end
378
-
379
- test '#each_line handles separator and limit argument when in read-only namespace' do
380
- p = SafePath.new('test_space_r').join('test_file_rw_not_empty')
381
-
382
- f = SafeFile.new(p, 'r')
383
- assert_equal ['I am', ' not ', 'em', 'pty'], f.each_line('m', 5).to_a
384
- f.close
385
- end
386
-
387
- ################################################################################
388
- # .path
389
-
390
- test '#path should return instance of SafePath' do
391
- p = SafePath.new('test_space_r').join('test_file_rw_not_empty')
392
-
393
- f = SafeFile.new(p)
394
- assert_equal SafePath, f.path.class
395
- refute_equal p.object_id, f.path.object_id
396
- assert_equal p, f.path
397
- end
398
-
399
- ################################################################################
400
- # .close
401
-
402
- test '#close should close the file' do
403
- p = SafePath.new('test_space_w').join('test_file_rw')
404
- f = SafeFile.new(p, 'w')
405
- f.write 'test'
406
- f.close
407
- end
408
-
409
- ################################################################################
410
- # ::extname
411
-
412
- test '::extname should accept safe_path only' do
413
- assert_raises ArgumentError do
414
- SafeFile.extname 'bad/extention.rb'
415
- end
416
- end
417
-
418
- test '::extname should NOT check pathspace permissions' do
419
- read_only_path = SafePath.new('test_space_r').join('test_file_rw_not_empty')
420
- write_only_path = SafePath.new('test_space_w').join('test_file_rw_not_empty')
421
-
422
- SafeFile.extname read_only_path
423
- SafeFile.extname write_only_path
424
- end
425
-
426
- test '::extname should return the extention only' do
427
- assert_equal '.rb', SafeFile.extname(SafePath.new('test_space_r').join('test_file.rb'))
428
- assert_equal '', SafeFile.extname(SafePath.new('test_space_r').join('test_file'))
429
- end
430
-
431
- ################################################################################
432
- # ::basename
433
-
434
- test '::basename should accept safe_path only' do
435
- assert_raises ArgumentError do
436
- SafeFile.basename('some/evil/path.rb')
437
- end
438
-
439
- assert_raises ArgumentError do
440
- SafeFile.basename('some/evil/path.rb', '.rb')
441
- end
442
- end
443
-
444
- test '::basename should NOT check pathspace permissions' do
445
- read_only_path = SafePath.new('test_space_r').join('test_file_rw_not_empty')
446
- write_only_path = SafePath.new('test_space_w').join('test_file_rw_not_empty')
447
-
448
- SafeFile.basename read_only_path
449
- SafeFile.basename write_only_path
450
- end
451
-
452
- test '::basename should should return the basename' do
453
- p = SafePath.new('test_space_rw').join('myfile.rb')
454
-
455
- assert_equal 'myfile.rb', SafeFile.basename(p)
456
- assert_equal 'myfile', SafeFile.basename(p, '.rb')
457
- end
458
-
459
- ################################################################################
460
- # ::readlines
461
-
462
- test "::readlines shouldn't accept more than 2 and less than 1 arguments" do
463
- p = SafePath.new('test_space_r').join('test_file_rw')
464
- assert_raises ArgumentError do
465
- SafeFile.readlines
466
- end
467
-
468
- assert_raises ArgumentError do
469
- SafeFile.readlines(p, 'junk_argument1', :junk_argument2)
470
- end
471
-
472
- assert_raises ArgumentError do
473
- SafeFile.readlines('junk/path/to/file.rb')
474
- end
475
- end
476
-
477
- test '::readlines should check pathspace permissions' do
478
- p = SafePath.new('test_space_w').join('test_file_rw')
479
- assert_raises SecurityError do
480
- SafeFile.readlines(p)
481
- end
482
- end
483
-
484
- test '::readlines should read lines from file' do
485
- p = SafePath.new('test_space_r').join('test_file_rw')
486
- # Use file because this test should be independent on the rest of the functionality of SafeFile
487
- File.open(p, 'w') do |f|
488
- f.write "there are three\nlines in this file\nand eight words"
489
- end
490
-
491
- lines = SafeFile.readlines(p)
492
-
493
- assert_equal 3, lines.length
494
- assert_equal "there are three\n", lines[0]
495
- assert_equal "lines in this file\n", lines[1]
496
- assert_equal 'and eight words', lines[2]
497
-
498
- lines = SafeFile.readlines(p, ' ')
499
- assert_equal 8, lines.length
500
- assert_equal 'there ', lines[0]
501
- end
502
-
503
- ################################################################################
504
- # ::directory?
505
-
506
- test '::directory? should accept only safe_path' do
507
- assert_raises ArgumentError do
508
- SafeFile.directory?('some/junk/path')
509
- end
510
- end
511
-
512
- test '::directory? should NOT check for pathspace permissions' do
513
- read_only_path = SafePath.new('test_space_r').join('test_file_rw_not_empty')
514
- write_only_path = SafePath.new('test_space_w').join('test_file_rw_not_empty')
515
-
516
- SafeFile.directory?(read_only_path)
517
- SafeFile.directory?(write_only_path)
518
- end
519
-
520
- test '::directory? should return true if the path is a directory and false otherwise' do
521
- p = SafePath.new('test_space_r')
522
- assert SafeFile.directory?(p)
523
- refute SafeFile.directory?(p.join('test_file_rw_not_empty'))
524
- end
525
-
526
- ################################################################################
527
- # ::exist? ::exists?
528
-
529
- test '::exist? and ::exists? should accept only safe_path' do
530
- assert_raises ArgumentError do
531
- SafeFile.exist?('some/junk/path')
532
- end
533
-
534
- assert_raises ArgumentError do
535
- SafeFile.exist?('some/junk/path')
536
- end
537
- end
538
-
539
- test '::exist? and ::exists? should NOT check pathspace permissions' do
540
- read_only_path = SafePath.new('test_space_r').join('test_file_rw_not_empty')
541
- write_only_path = SafePath.new('test_space_w').join('test_file_rw_not_empty')
542
-
543
- SafeFile.exist?(read_only_path)
544
- SafeFile.exist?(write_only_path)
545
- SafeFile.exist?(read_only_path)
546
- SafeFile.exist?(write_only_path)
547
- end
548
-
549
- test 'exist? and exists? should return true if the file exists and false otherwise' do
550
- real = SafePath.new('test_space_r').join('test_file_rw')
551
- junk = SafePath.new('test_space_r').join('test_file_rw_junk')
552
-
553
- assert SafeFile.exist?(real)
554
- assert SafeFile.exist?(real)
555
-
556
- refute SafeFile.exist?(junk)
557
- refute SafeFile.exist?(junk)
558
- end
559
-
560
- ################################################################################
561
- # ::file?
562
-
563
- test '::file? should accept safe_path only' do
564
- assert_raises ArgumentError do
565
- SafeFile.file?('some/junk.path')
566
- end
567
- end
568
-
569
- test '::file? should NOT check pathspace permissions' do
570
- read_only_path = SafePath.new('test_space_r').join('test_file_rw_not_empty')
571
- write_only_path = SafePath.new('test_space_w').join('test_file_rw_not_empty')
572
-
573
- SafeFile.file?(read_only_path)
574
- SafeFile.file?(write_only_path)
575
- end
576
-
577
- test 'file? should return true of the path is file and false otherwise' do
578
- file = SafePath.new('test_space_r').join('test_file_rw')
579
- dir = SafePath.new('test_space_r')
580
-
581
- assert SafeFile.file?(file)
582
- refute SafeFile.file?(dir)
583
- end
584
-
585
- ################################################################################
586
- # ::zero?
587
-
588
- test '::zero? should accept only SafePath' do
589
- assert_raises ArgumentError do
590
- SafeFile.zero? SafePath.new('test_space_w').join!('test_file_rw').to_s
591
- end
592
- end
593
-
594
- test '::zero? should NOT check pathspace permissions' do
595
- read_only_path = SafePath.new('test_space_r').join('test_file_rw_not_empty')
596
- write_only_path = SafePath.new('test_space_w').join('test_file_rw_not_empty')
597
-
598
- SafeFile.zero?(read_only_path)
599
- SafeFile.zero?(write_only_path)
600
- end
601
-
602
- test '::zero? should return true when the file is empty and false otherwise' do
603
- assert SafeFile.zero? SafePath.new('test_space_rw').join!('test_file_rw')
604
- refute SafeFile.zero?(SafePath.new('test_space_rw').join!('test_file_rw_not_empty'))
605
- end
606
-
607
- ################################################################################
608
- # ::dirname
609
-
610
- test '::dirname should accept safe_path only' do
611
- assert_raises ArgumentError do
612
- SafeFile.dirname('some/junk/path')
613
- end
614
- end
615
-
616
- test '::dirname should NOT check pathspace permissions' do
617
- read_only_path = SafePath.new('test_space_r').join('test_file_rw_not_empty')
618
- write_only_path = SafePath.new('test_space_w').join('test_file_rw_not_empty')
619
-
620
- SafeFile.dirname(read_only_path)
621
- SafeFile.dirname(write_only_path)
622
- end
623
-
624
- test '::dirname should return the directory' do
625
- p = SafePath.new('test_space_r')
626
-
627
- assert_equal SafePath, SafeFile.dirname(p.join('test_file_rw')).class
628
- refute_equal p.object_id, SafeFile.dirname(p.join('test_file_rw')).object_id
629
-
630
- assert_equal p.to_s, SafeFile.dirname(p.join('test_file_rw')).to_s
631
- end
632
-
633
- ################################################################################
634
- # ::delete
635
-
636
- test '::delete should accept safe_path only' do
637
- assert_raises ArgumentError do
638
- SafeFile.delete('test_path')
639
- end
640
- end
641
-
642
- test '::delete should check pathspace permissions' do
643
- assert_raises SecurityError do
644
- SafeFile.delete(SafePath.new('test_space_r').join!('test_file_r'))
645
- end
646
- end
647
-
648
- test '::delete should delete file/files' do
649
- sp = SafePath.new('test_space_w').join!('new_test_file')
650
-
651
- group = [SafePath.new('test_space_w').join!('new_test_file1'),
652
- SafePath.new('test_space_w').join!('new_test_file2'),
653
- SafePath.new('test_space_w').join!('new_test_file3')]
654
-
655
- (group + [sp]).each do |fname|
656
- # This test should't depend on the rest of the functionality of SafeFile
657
- File.open(fname, 'w') { |f| f.write 'test' }
658
- end
659
-
660
- SafeFile.delete sp
661
-
662
- refute File.exist?(sp)
663
-
664
- SafeFile.delete(*group)
665
-
666
- group.each do |fname|
667
- refute File.exist?(fname)
668
- end
669
- end
670
- end