file-find 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file-find
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
@@ -35,36 +35,50 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date:
38
+ date:
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: sys-admin
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 1.6.0
46
+ version: '1.7'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 1.6.0
53
+ version: '1.7'
54
54
  - !ruby/object:Gem::Dependency
55
- name: test-unit
55
+ name: rspec
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0'
60
+ version: '3.9'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0'
67
+ version: '3.9'
68
+ - !ruby/object:Gem::Dependency
69
+ name: fakefs
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.3'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.3'
68
82
  - !ruby/object:Gem::Dependency
69
83
  name: rake
70
84
  requirement: !ruby/object:Gem::Requirement
@@ -87,36 +101,34 @@ description: |2
87
101
  email: djberg96@gmail.com
88
102
  executables: []
89
103
  extensions: []
90
- extra_rdoc_files:
91
- - README.rdoc
92
- - CHANGES.rdoc
93
- - MANIFEST.rdoc
104
+ extra_rdoc_files: []
94
105
  files:
95
106
  - LICENSE
96
- - test
97
- - test/test_file_find.rb
98
107
  - file-find.gemspec
108
+ - spec
109
+ - spec/file_find_spec.rb
110
+ - README.md
99
111
  - Rakefile
112
+ - MANIFEST.md
100
113
  - certs
101
114
  - certs/djberg96_pub.pem
102
115
  - lib
103
116
  - lib/file-find.rb
104
117
  - lib/file
105
118
  - lib/file/find.rb
106
- - CHANGES.rdoc
107
- - MANIFEST.rdoc
108
- - README.rdoc
119
+ - Gemfile
120
+ - CHANGES.md
109
121
  homepage: http://github.com/djberg96/file-find
110
122
  licenses:
111
123
  - Apache-2.0
112
124
  metadata:
113
125
  homepage_uri: https://github.com/djberg96/file-find
114
126
  bug_tracker_uri: https://github.com/djberg96/file-find/issues
115
- changelog_uri: https://github.com/djberg96/file-find/blob/master/CHANGES
127
+ changelog_uri: https://github.com/djberg96/file-find/blob/master/CHANGES.md
116
128
  documentation_uri: https://github.com/djberg96/file-find/wiki
117
129
  source_code_uri: https://github.com/djberg96/file-find
118
130
  wiki_uri: https://github.com/djberg96/file-find/wiki
119
- post_install_message:
131
+ post_install_message:
120
132
  rdoc_options: []
121
133
  require_paths:
122
134
  - lib
@@ -131,9 +143,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
143
  - !ruby/object:Gem::Version
132
144
  version: '0'
133
145
  requirements: []
134
- rubygems_version: 3.1.4
135
- signing_key:
146
+ rubygems_version: 3.0.3
147
+ signing_key:
136
148
  specification_version: 4
137
149
  summary: A better way to find files
138
150
  test_files:
139
- - test/test_file_find.rb
151
+ - spec/file_find_spec.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,589 +0,0 @@
1
- ######################################################################
2
- # test_file_find.rb
3
- #
4
- # Test case for the File::Find package. You should run this via the
5
- # 'rake test' task.
6
- ######################################################################
7
- require 'test-unit'
8
- require 'fileutils'
9
- require 'file/find'
10
- require 'sys/admin'
11
- require 'tmpdir'
12
-
13
- if File::ALT_SEPARATOR
14
- require 'win32/file'
15
- require 'win32/security'
16
- end
17
-
18
- include FileUtils
19
-
20
- class TC_File_Find < Test::Unit::TestCase
21
- def self.startup
22
- Dir.chdir(File.dirname(File.expand_path(__FILE__)))
23
-
24
- @@windows = File::ALT_SEPARATOR
25
- @@jruby = RUBY_PLATFORM.match('java')
26
-
27
- if @@windows
28
- @@elevated = Win32::Security.elevated_security?
29
- if @@elevated
30
- @@loguser = Sys::Admin.get_group("Administrators", :LocalAccount => true)
31
- else
32
- @@loguser = Sys::Admin.get_user(Sys::Admin.get_login, :LocalAccount => true)
33
- end
34
- else
35
- @@loguser = Sys::Admin.get_user(Sys::Admin.get_login)
36
- @@logroup = Sys::Admin.get_group(@@loguser.gid)
37
- end
38
- end
39
-
40
- def setup
41
- @file_rb = 'test1.rb'
42
- @file_txt1 = 'test1.txt'
43
- @file_txt2 = 'foo.txt'
44
- @file_doc = 'foo.doc'
45
- @directory1 = 'dir1'
46
- @directory2 = 'dir2'
47
-
48
- File.open(@file_rb, 'w'){}
49
- File.open(@file_txt1, 'w'){}
50
- File.open(@file_txt2, 'w'){}
51
- File.open(@file_doc, 'w'){}
52
-
53
- @link1 = 'link1'
54
-
55
- if @@windows
56
- File.symlink(@file_rb, @link1) if @@elevated
57
- else
58
- File.symlink(@file_rb, @link1)
59
- end
60
-
61
- Dir.mkdir(@directory1) unless File.exist?(@directory1)
62
- Dir.mkdir(@directory2) unless File.exist?(@directory2)
63
-
64
- File.open(File.join(@directory1, 'bar.txt'), 'w'){}
65
- File.open(File.join(@directory2, 'baz.txt'), 'w'){}
66
-
67
- @rule1 = File::Find.new(:name => '*.txt')
68
- @rule2 = File::Find.new
69
- end
70
-
71
- test "version constant is set to expected value" do
72
- assert_equal('0.4.4', File::Find::VERSION)
73
- assert_true(File::Find::VERSION.frozen?)
74
- end
75
-
76
- test "path accessor basic functionality" do
77
- assert_respond_to(@rule1, :path)
78
- assert_respond_to(@rule1, :path=)
79
- end
80
-
81
- test "path method returns expected value" do
82
- assert_equal(Dir.pwd, @rule1.path)
83
- end
84
-
85
- test "options accessor basic functionality" do
86
- assert_respond_to(@rule1, :options)
87
- assert_respond_to(@rule1, :options=)
88
- end
89
-
90
- test "options method returns expected value" do
91
- assert_equal({:name => '*.txt'}, @rule1.options)
92
- end
93
-
94
- test "atime accessor basic functionality" do
95
- assert_respond_to(@rule1, :atime)
96
- assert_respond_to(@rule1, :atime=)
97
- end
98
-
99
- test "atime method returns expected default value" do
100
- assert_nil(@rule1.atime)
101
- end
102
-
103
- test "find with atime option works as expected" do
104
- rule1 = File::Find.new(:name => "*.rb", :atime => 0)
105
- rule2 = File::Find.new(:name => "*.rb", :atime => 1)
106
-
107
- assert_false(rule1.find.empty?)
108
- assert_true(rule2.find.empty?)
109
- end
110
-
111
- test "ctime accessor basic functionality" do
112
- assert_respond_to(@rule1, :ctime)
113
- assert_respond_to(@rule1, :ctime=)
114
- end
115
-
116
- test "ctime method returns expected default value" do
117
- assert_nil(@rule1.ctime)
118
- end
119
-
120
- test "find with ctime option works as expected" do
121
- rule1 = File::Find.new(:name => "*.rb", :ctime => 0)
122
- rule2 = File::Find.new(:name => "*.rb", :ctime => 1)
123
-
124
- assert_false(rule1.find.empty?)
125
- assert_true(rule2.find.empty?)
126
- end
127
-
128
- test "find method basic functionality" do
129
- assert_respond_to(@rule1, :find)
130
- assert_nothing_raised{ @rule1.find }
131
- end
132
-
133
- test "find method returns expected value" do
134
- assert_kind_of(Array, @rule1.find)
135
- assert_nil(@rule1.find{})
136
- end
137
-
138
- test "filetest accessor basic functionality" do
139
- assert_respond_to(@rule1, :filetest)
140
- assert_respond_to(@rule1, :filetest=)
141
- assert_nothing_raised{ @rule1.filetest }
142
- end
143
-
144
- test "filetest method returns expected value" do
145
- assert_kind_of(Array, @rule1.filetest)
146
- end
147
-
148
- test "valid filetest options work as expected" do
149
- assert_nothing_raised{ File::Find.new(:readable? => true) }
150
- assert_nothing_raised{ File::Find.new(:writable? => true) }
151
- end
152
-
153
- test "find method works with filetest option" do
154
- rule = File::Find.new(:name => "*.doc", :writable? => true)
155
- File.chmod(0644, @file_doc)
156
-
157
- assert_equal([@file_doc], rule.find.map{ |f| File.basename(f) })
158
-
159
- File.chmod(0444, @file_doc)
160
-
161
- assert_equal([], rule.find)
162
- end
163
-
164
- test "mtime accessor basic functionality" do
165
- assert_respond_to(@rule1, :mtime)
166
- assert_respond_to(@rule1, :mtime=)
167
- end
168
-
169
- test "mtime method returns expected default value" do
170
- assert_nil(@rule1.mtime)
171
- end
172
-
173
- test "find with mtime option works as expected" do
174
- rule1 = File::Find.new(:name => "*.rb", :mtime => 0)
175
- rule2 = File::Find.new(:name => "*.rb", :mtime => 1)
176
-
177
- assert_false(rule1.find.empty?)
178
- assert_true(rule2.find.empty?)
179
- end
180
-
181
- test "ftype accessor basic functionality" do
182
- assert_respond_to(@rule1, :ftype)
183
- assert_respond_to(@rule1, :ftype=)
184
- end
185
-
186
- test "ftype method returns expected default value" do
187
- assert_nil(@rule1.ftype)
188
- end
189
-
190
- test "ftype method works as expected" do
191
- rule1 = File::Find.new(:name => "*.rb", :ftype => "file")
192
- rule2 = File::Find.new(:name => "*.rb", :ftype => "characterSpecial")
193
-
194
- assert_false(rule1.find.empty?)
195
- assert_true(rule2.find.empty?)
196
- end
197
-
198
- test "group accessor basic functionality" do
199
- assert_respond_to(@rule1, :group)
200
- assert_respond_to(@rule1, :group=)
201
- end
202
-
203
- test "group method returns expected default value" do
204
- assert_nil(@rule1.group)
205
- end
206
-
207
- # TODO: Update test for Windows
208
- test "find with numeric group id works as expected" do
209
- omit_if(@@windows, 'group test skipped on MS Windows')
210
- @rule1 = File::Find.new(:name => '*.doc', :group => @@loguser.gid)
211
- assert_equal([File.expand_path(@file_doc)], @rule1.find)
212
- end
213
-
214
- # TODO: Update test for Windows
215
- test "find with string group id works as expected" do
216
- omit_if(@@windows, 'group test skipped on MS Windows')
217
- @rule1 = File::Find.new(:name => '*.doc', :group => @@logroup.name)
218
- assert_equal([File.expand_path(@file_doc)], @rule1.find)
219
- end
220
-
221
- test "find with bogus group returns empty results" do
222
- omit_if(@@windows, 'group test skipped on MS Windows')
223
- @rule1 = File::Find.new(:name => '*.doc', :group => 'totallybogus')
224
- @rule2 = File::Find.new(:name => '*.doc', :group => 99999999)
225
- assert_equal([], @rule1.find)
226
- assert_equal([], @rule2.find)
227
- end
228
-
229
- test "inum accessor basic functionality" do
230
- assert_respond_to(@rule1, :inum)
231
- assert_respond_to(@rule1, :inum=)
232
- end
233
-
234
- test "inum method returns expected default value" do
235
- assert_nil(@rule1.inum)
236
- end
237
-
238
- test "follow accessor basic functionality" do
239
- assert_respond_to(@rule1, :follow)
240
- assert_respond_to(@rule1, :follow=)
241
- end
242
-
243
- test "follow method returns expected default value" do
244
- assert_true(@rule1.follow)
245
- end
246
-
247
- test "links accessor basic functionality" do
248
- assert_respond_to(@rule1, :links)
249
- assert_respond_to(@rule1, :links=)
250
- end
251
-
252
- test "links method returns expected default value" do
253
- assert_nil(@rule1.links)
254
- end
255
-
256
- test "links method returns expected result" do
257
- omit_if(@@windows && !@@elevated)
258
- @rule1 = File::Find.new(:name => '*.rb', :links => 2)
259
- @rule2 = File::Find.new(:name => '*.doc', :links => 1)
260
-
261
- assert_equal([], @rule1.find)
262
- assert_equal([File.expand_path(@file_doc)], @rule2.find)
263
- end
264
-
265
- def test_maxdepth_basic
266
- assert_respond_to(@rule1, :maxdepth)
267
- assert_respond_to(@rule1, :maxdepth=)
268
- assert_nil(@rule1.maxdepth)
269
- end
270
-
271
- # This test is a little uglier because we actually check to make sure
272
- # we're looking at the right subdir, not just a filename shows up.
273
- # I did this because I'm a little paranoid about the directory
274
- # not getting mangled. - jlawler.
275
- #
276
- test "find method works on dirs that contain brackets" do
277
- omit_if(@@windows, 'dirs with brackets test skipped on MS Windows')
278
-
279
- bracket_files = [ 'bracket/a[1]/a.foo', 'bracket/a [2] /b.foo', 'bracket/[a] b [c]/d.foo' ].sort
280
- bracket_paths = [ 'bracket/a[1]', 'bracket/a [2] ', 'bracket/[a] b [c]', 'bracket/[z] x' ].sort
281
-
282
- bracket_paths.each{ |e| mkpath(e) }
283
- bracket_files.each{ |e| touch(e) }
284
-
285
- @file_rule = File::Find.new(
286
- :ftype => 'file',
287
- :path => ['bracket']
288
- )
289
-
290
- @dir_rule = File::Find.new(
291
- :path => ['bracket'],
292
- :ftype => 'directory'
293
- )
294
-
295
- file_results = @file_rule.find.sort
296
-
297
- assert_equal(bracket_files.size,file_results.size)
298
- path = file_results.first.chomp(bracket_files.first)
299
-
300
- # Confirm the first thing in results is the first thing in bracket_paths
301
- assert_not_equal(path, file_results.first)
302
- assert_equal(bracket_files, file_results.map{ |e| e.sub(path,'') }.sort )
303
- assert_equal(bracket_paths, @dir_rule.find.sort )
304
- end
305
-
306
- test "find with maxdepth option returns expected results" do
307
- mkpath('a1/a2/a3')
308
- touch('a1/a.foo')
309
- touch('a1/a2/b.foo')
310
- touch('a1/a2/c.foo')
311
- touch('a1/a2/a3/d.foo')
312
- touch('a1/a2/a3/e.foo')
313
- touch('a1/a2/a3/f.foo')
314
-
315
- @rule2.pattern = "*.foo"
316
- @rule2.maxdepth = 1
317
- assert_equal([], @rule2.find)
318
-
319
- @rule2.maxdepth = 2
320
- assert_equal(['a.foo'], @rule2.find.map{ |e| File.basename(e) })
321
-
322
- @rule2.maxdepth = 3
323
- assert_equal(['a.foo', 'b.foo', 'c.foo'], @rule2.find.map{ |e| File.basename(e) }.sort)
324
-
325
- @rule2.maxdepth = nil
326
- assert_equal(
327
- ['a.foo', 'b.foo', 'c.foo', 'd.foo', 'e.foo', 'f.foo'],
328
- @rule2.find.map{ |e| File.basename(e) }.sort
329
- )
330
- end
331
-
332
- test "find with maxdepth option returns expected results for directories" do
333
- mkpath('a/b/c')
334
- @rule2.pattern = "c"
335
-
336
- @rule2.maxdepth = 1
337
- assert_equal([], @rule2.find)
338
-
339
- @rule2.maxdepth = 2
340
- assert_equal([], @rule2.find)
341
-
342
- @rule2.maxdepth = 3
343
- assert_equal(['c'], @rule2.find.map{ |e| File.basename(e) })
344
- end
345
-
346
- test "mindepth accessor basic functionality" do
347
- assert_respond_to(@rule1, :mindepth)
348
- assert_respond_to(@rule1, :mindepth=)
349
- end
350
-
351
- test "mindepth method returns expected default value" do
352
- assert_nil(@rule1.mindepth)
353
- end
354
-
355
- test "find with mindepth option returns expected results" do
356
- mkpath('a1/a2/a3')
357
- touch('z.min')
358
- touch('a1/a.min')
359
- touch('a1/a2/b.min')
360
- touch('a1/a2/c.min')
361
- touch('a1/a2/a3/d.min')
362
- touch('a1/a2/a3/e.min')
363
- touch('a1/a2/a3/f.min')
364
-
365
- @rule2.pattern = "*.min"
366
-
367
- @rule2.mindepth = 0
368
- assert_equal(
369
- ['a.min', 'b.min', 'c.min', 'd.min', 'e.min', 'f.min', 'z.min'],
370
- @rule2.find.map{ |e| File.basename(e) }.sort
371
- )
372
-
373
- @rule2.mindepth = 1
374
- assert_equal(
375
- ['a.min', 'b.min', 'c.min', 'd.min', 'e.min', 'f.min', 'z.min'],
376
- @rule2.find.map{ |e| File.basename(e) }.sort
377
- )
378
-
379
- @rule2.mindepth = 2
380
- assert_equal(
381
- ['a.min', 'b.min', 'c.min', 'd.min', 'e.min', 'f.min'],
382
- @rule2.find.map{ |e| File.basename(e) }.sort
383
- )
384
-
385
- @rule2.mindepth = 3
386
- assert_equal(
387
- ['b.min', 'c.min', 'd.min', 'e.min', 'f.min'],
388
- @rule2.find.map{ |e| File.basename(e) }.sort
389
- )
390
-
391
- @rule2.mindepth = 4
392
- assert_equal(['d.min', 'e.min', 'f.min'], @rule2.find.map{ |e| File.basename(e) }.sort)
393
-
394
- @rule2.mindepth = 5
395
- assert_equal([], @rule2.find.map{ |e| File.basename(e) })
396
- end
397
-
398
- test "find with mindepth option returns expected results for directories" do
399
- mkpath('a/b/c')
400
- @rule2.pattern = "a"
401
-
402
- @rule2.mindepth = 1
403
- assert_equal(['a'], @rule2.find.map{ |e| File.basename(e) })
404
-
405
- @rule2.mindepth = 2
406
- assert_equal([], @rule2.find)
407
-
408
- @rule2.mindepth = 3
409
- assert_equal([], @rule2.find)
410
- end
411
-
412
- test "mount accessor basic functionality" do
413
- assert_respond_to(@rule1, :mount)
414
- assert_respond_to(@rule1, :mount=)
415
- end
416
-
417
- test "mount method returns expected default value" do
418
- assert_nil(@rule1.mount)
419
- end
420
-
421
- test "name accessor basic functionality" do
422
- assert_respond_to(@rule1, :name)
423
- assert_respond_to(@rule1, :name=)
424
- end
425
-
426
- test "name method returns expected default value" do
427
- assert_equal('*.txt', @rule1.name)
428
- end
429
-
430
- test "pattern accessor basic functionality" do
431
- assert_respond_to(@rule1, :pattern)
432
- assert_respond_to(@rule1, :pattern=)
433
- end
434
-
435
- test "pattern is an alias for name" do
436
- assert_alias_method(@rule1, :name, :pattern)
437
- assert_alias_method(@rule1, :name=, :pattern=)
438
- end
439
-
440
- test "perm accessor basic functionality" do
441
- assert_respond_to(@rule1, :perm)
442
- assert_respond_to(@rule1, :perm=)
443
- end
444
-
445
- test "perm method returns expected default value" do
446
- assert_nil(@rule1.perm)
447
- end
448
-
449
- test "perm method returns expected results" do
450
- File.chmod(0444, @file_rb)
451
- File.chmod(0644, @file_txt1)
452
-
453
- results = File::Find.new(:name => "test1*", :perm => 0644).find
454
-
455
- assert_equal(1, results.length)
456
- assert_equal('test1.txt', File.basename(results.first))
457
- end
458
-
459
- test "perm method works with symbolic permissions" do
460
- omit_if(@@windows, 'symbolic perm test skipped on MS Windows')
461
-
462
- File.chmod(0664, @file_rb) # test1.rb
463
- File.chmod(0644, @file_txt1) # test1.txt
464
- results1 = File::Find.new(:name => "test1*", :perm => "g=rw").find
465
- results2 = File::Find.new(:name => "test1*", :perm => "u=rw").find
466
-
467
- assert_equal(1, results1.length)
468
- assert_equal(2, results2.length)
469
- assert_equal('test1.rb', File.basename(results1.first))
470
- assert_equal(['test1.rb', 'test1.txt'], results2.map{ |e| File.basename(e) }.sort)
471
- end
472
-
473
- test "prune accessor basic functionality" do
474
- assert_respond_to(@rule1, :prune)
475
- assert_respond_to(@rule1, :prune=)
476
- end
477
-
478
- test "prune method returns expected default value" do
479
- assert_nil(@rule1.prune)
480
- end
481
-
482
- test "find method with prune option works as expected" do
483
- rule = File::Find.new(:name => "*.txt", :prune => 'foo')
484
- assert_equal('test1.txt', File.basename(rule.find.first))
485
- end
486
-
487
- test "size accessor basic functionality" do
488
- assert_respond_to(@rule1, :size)
489
- assert_respond_to(@rule1, :size=)
490
- end
491
-
492
- test "size method returns expected default value" do
493
- assert_nil(@rule1.size)
494
- end
495
-
496
- test "user accessor basic functionality" do
497
- assert_respond_to(@rule1, :user)
498
- assert_respond_to(@rule1, :user=)
499
- end
500
-
501
- test "user method returns expected default value" do
502
- assert_nil(@rule1.user)
503
- end
504
-
505
- test "user method works with numeric id as expected" do
506
- if @@windows && @@elevated
507
- uid = @@loguser.gid # Windows assigns the group if any member is an admin
508
- else
509
- uid = @@loguser.uid
510
- end
511
-
512
- @rule1 = File::Find.new(:name => '*.doc', :user => uid)
513
- assert_equal([File.expand_path(@file_doc)], @rule1.find)
514
- end
515
-
516
- test "user method works with string as expected" do
517
- omit_if(@@windows && @@elevated)
518
- @rule1 = File::Find.new(:name => '*.doc', :user => @@loguser.name)
519
- assert_equal([File.expand_path(@file_doc)], @rule1.find)
520
- end
521
-
522
- test "find method with user option using invalid user returns expected results" do
523
- @rule1 = File::Find.new(:name => '*.doc', :user => 'totallybogus')
524
- @rule2 = File::Find.new(:name => '*.doc', :user => 99999999)
525
- assert_equal([], @rule1.find)
526
- assert_equal([], @rule2.find)
527
- end
528
-
529
- test "previous method basic functionality" do
530
- assert_respond_to(@rule1, :previous)
531
- end
532
-
533
- test "an error is raised if the path does not exist" do
534
- assert_raise(Errno::ENOENT){ File::Find.new(:path => '/bogus/dir').find }
535
- end
536
-
537
- test "an error is raised if an invalid option is passed" do
538
- assert_raise(ArgumentError){ File::Find.new(:bogus => 1) }
539
- assert_raise(ArgumentError){ File::Find.new(:bogus? => true) }
540
- end
541
-
542
- # TODO: Update test for Windows
543
- test 'eloop handling works as expected' do
544
- omit_if(@@windows, 'eloop handling test skipped on MS Windows')
545
-
546
- begin
547
- dir_eloop = ::Dir.mktmpdir
548
-
549
- Dir.chdir(dir_eloop) do
550
- File.symlink('eloop0', 'eloop1')
551
- File.symlink('eloop1', 'eloop0')
552
- expecting = ['./eloop0', './eloop1']
553
-
554
- results = File::Find.new(:path => '.', :follow => true).find
555
- assert_equal(expecting, results.sort)
556
- end
557
- ensure
558
- rm_rf(dir_eloop)
559
- end
560
- end
561
-
562
- def teardown
563
- rm_rf(@file_rb)
564
- rm_rf(@file_txt1)
565
- rm_rf(@file_txt2)
566
- rm_rf(@file_doc)
567
- rm_rf(@directory1)
568
- rm_rf(@directory2)
569
- rm_rf(@link1) #unless @@windows
570
- rm_rf('a')
571
- rm_rf('a1')
572
- rm_rf('bracket')
573
- rm_rf('z.min') if File.exist?('z.min')
574
-
575
- @rule1 = nil
576
- @rule2 = nil
577
- @file_rb = nil
578
- @file_txt1 = nil
579
- @file_txt2 = nil
580
- @file_doc = nil
581
- end
582
-
583
- def self.shutdown
584
- @@windows = nil
585
- @@jruby = nil
586
- @@elevated = nil if @@windows
587
- @@logroup = nil unless @@windows
588
- end
589
- end