test/test_file_find.rb in file-find-0.2.5 vs test/test_file_find.rb in file-find-0.3.0

- old
+ new

@@ -50,11 +50,11 @@ @rule1 = File::Find.new(:name => '*.txt') @rule2 = File::Find.new end def test_version - assert_equal('0.2.5', File::Find::VERSION) + assert_equal('0.3.0', File::Find::VERSION) end def test_path assert_respond_to(@rule1, :path) assert_respond_to(@rule1, :path=) @@ -98,10 +98,38 @@ def test_find_basic assert_respond_to(@rule1, :find) assert_nothing_raised{ @rule1.find } end + def test_find + assert_kind_of(Array, @rule1.find) + assert_nil(@rule1.find{}) + end + + def test_filetest_basic + assert_respond_to(@rule1, :filetest) + assert_respond_to(@rule1, :filetest=) + assert_nothing_raised{ @rule1.filetest } + assert_kind_of(Array, @rule1.filetest) + end + + def test_filetest_valid_options + assert_nothing_raised{ File::Find.new(:readable? => true) } + assert_nothing_raised{ File::Find.new(:writable? => true) } + end + + def test_filetest + rule = File::Find.new(:name => "*.doc", :writable? => true) + File.chmod(0644, @file4) + + assert_equal([@file4], rule.find.map{ |f| File.basename(f) }) + + File.chmod(0444, @file4) + + assert_equal([], rule.find) + end + def test_mtime rule1 = File::Find.new(:name => "*.rb", :mtime => 0) rule2 = File::Find.new(:name => "*.rb", :mtime => 1) assert_false(rule1.find.empty?) @@ -351,9 +379,10 @@ end def test_expected_errors assert_raise(Errno::ENOENT){ File::Find.new(:path => '/bogus/dir').find } assert_raise(ArgumentError){ File::Find.new(:bogus => 1) } + assert_raise(ArgumentError){ File::Find.new(:bogus? => true) } end def teardown rm_rf(@file1) rm_rf(@file2)