PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 42 lines | 34 code | 8 blank | 0 comment | 0 complexity | 71745587a277f273bec9b82cb478ce42 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/recurse'
  2. require 'test/unit'
  3. require 'fileutils'
  4. require 'tmpdir'
  5. class TC_Dir_Recurse < Test::Unit::TestCase
  6. DIRS = %w{A A/B}
  7. FILES = %w{A.txt A/B.txt A/B/C.txt}
  8. def setup
  9. @location = File.join(Dir.tmpdir, self.class.name, Time.now.usec.to_s)
  10. DIRS.each do |x|
  11. FileUtils.mkdir_p(File.join(@location, x))
  12. end
  13. FILES.each do |x|
  14. File.open(File.join(@location, x), 'w'){ |f| f << "SPINICH" }
  15. end
  16. end
  17. def teardown
  18. FileUtils.rm_r(@location)
  19. end
  20. def test_recurse
  21. Dir.chdir @location do
  22. rs = (DIRS + FILES).sort
  23. fs = Dir.recurse.sort
  24. assert_equal( rs, fs, Dir.pwd )
  25. end
  26. end
  27. def test_ls_r
  28. Dir.chdir @location do
  29. rs = (DIRS + FILES).sort
  30. fs = Dir.ls_r.sort
  31. assert_equal( rs, fs, Dir.pwd )
  32. end
  33. end
  34. end