test_rake.rb 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. require File.expand_path('../helper', __FILE__)
  2. class TestRake < Rake::TestCase
  3. def test_each_dir_parent
  4. assert_equal ['a'], alldirs('a')
  5. assert_equal ['a/b', 'a'], alldirs('a/b')
  6. assert_equal ['/a/b', '/a', '/'], alldirs('/a/b')
  7. if File.dirname("c:/foo") == "c:"
  8. # Under Unix
  9. assert_equal ['c:/a/b', 'c:/a', 'c:'], alldirs('c:/a/b')
  10. assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
  11. else
  12. # Under Windows
  13. assert_equal ['c:/a/b', 'c:/a', 'c:/'], alldirs('c:/a/b')
  14. assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
  15. end
  16. end
  17. def alldirs(fn)
  18. result = []
  19. Rake.each_dir_parent(fn) { |d| result << d }
  20. result
  21. end
  22. def test_can_override_application
  23. old_app = Rake.application
  24. fake_app = Object.new
  25. Rake.application = fake_app
  26. assert_equal fake_app, Rake.application
  27. ensure
  28. Rake.application = old_app
  29. end
  30. def test_original_dir_reports_current_dir
  31. assert_equal @tempdir, Rake.original_dir
  32. end
  33. end