PageRenderTime 53ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/core/dir/test_ascend.rb

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 40 lines | 33 code | 7 blank | 0 comment | 0 complexity | 91fa40e404ee1d4a16b1e656c31e2898 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
  1. require 'facets/dir/ascend'
  2. require 'test/unit'
  3. require 'tmpdir'
  4. class TC_Dir_Ascend < Test::Unit::TestCase
  5. DIRS = %w{A A/B}
  6. FILES = %w{A.txt A/B.txt A/B/C.txt}
  7. def setup
  8. @location = File.join(Dir.tmpdir, self.class.name, Time.now.usec.to_s)
  9. @startdir = File.join(@location)
  10. end
  11. def test_ascend
  12. c = []
  13. Dir.ascend(@startdir) do |path|
  14. c << path
  15. end
  16. rdir = @startdir
  17. c.each do |d|
  18. assert_equal(rdir, d)
  19. rdir = File.dirname(rdir)
  20. end
  21. end
  22. def test_ascend_exclude_current
  23. c = []
  24. Dir.ascend(@startdir, false) do |path|
  25. c << path
  26. end
  27. rdir = File.dirname(@startdir)
  28. c.each do |d|
  29. assert_equal(rdir, d)
  30. rdir = File.dirname(rdir)
  31. end
  32. end
  33. end