Sha256: 1d61756c75e81e2c0cfea76e3c8ab2ae5ef5c4df1a35c95daec052d3404c850e

Contents?: true

Size: 776 Bytes

Versions: 16

Compression:

Stored size: 776 Bytes

Contents

require 'facets/dir/ascend'
require 'test/unit'
require 'tmpdir'

class TC_Dir_Ascend < Test::Unit::TestCase

   DIRS  = %w{A A/B}
   FILES = %w{A.txt A/B.txt A/B/C.txt}

   def setup
     @location = File.join(Dir.tmpdir, self.class.name, Time.now.usec.to_s)
     @startdir = File.join(@location)
   end

   def test_ascend
     c = []
     Dir.ascend(@startdir) do |path|
       c << path
     end
     rdir = @startdir
     c.each do |d|
       assert_equal(rdir, d)
       rdir = File.dirname(rdir)
     end
   end

   def test_ascend_exclude_current
     c = []
     Dir.ascend(@startdir, false) do |path|
       c << path
     end
     rdir = File.dirname(@startdir)
     c.each do |d|
       assert_equal(rdir, d)
       rdir = File.dirname(rdir)
     end
   end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
facets-2.8.4 test/core/dir/test_ascend.rb
facets-2.8.3 test/core/dir/test_ascend.rb
facets-2.8.2 test/core/dir/test_ascend.rb
facets-2.8.1 test/core/dir/test_ascend.rb
facets-2.8.0 test/core/dir/test_ascend.rb
facets-2.7.0 test/core/dir/test_ascend.rb
facets-2.6.0 test/core/dir/test_ascend.rb
facets-2.4.0 test/dir/test_ascend.rb
facets-2.4.1 test/dir/test_ascend.rb
facets-2.4.2 test/core/dir/test_ascend.rb
facets-2.4.3 test/core/dir/test_ascend.rb
facets-2.4.4 test/core/dir/test_ascend.rb
facets-2.5.0 test/core/dir/test_ascend.rb
facets-2.4.5 test/core/dir/test_ascend.rb
facets-2.5.1 test/core/dir/test_ascend.rb
facets-2.5.2 test/core/dir/test_ascend.rb