2011-06-24 02:11:55 +04:00
|
|
|
require File.expand_path('../helper', __FILE__)
|
2009-10-02 23:07:55 +04:00
|
|
|
|
2011-06-24 02:11:55 +04:00
|
|
|
class TestRake < Rake::TestCase
|
2009-10-02 23:07:55 +04:00
|
|
|
def test_each_dir_parent
|
|
|
|
assert_equal ['a'], alldirs('a')
|
|
|
|
assert_equal ['a/b', 'a'], alldirs('a/b')
|
|
|
|
assert_equal ['/a/b', '/a', '/'], alldirs('/a/b')
|
|
|
|
if File.dirname("c:/foo") == "c:"
|
|
|
|
# Under Unix
|
|
|
|
assert_equal ['c:/a/b', 'c:/a', 'c:'], alldirs('c:/a/b')
|
|
|
|
assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
|
|
|
|
else
|
|
|
|
# Under Windows
|
|
|
|
assert_equal ['c:/a/b', 'c:/a', 'c:/'], alldirs('c:/a/b')
|
|
|
|
assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def alldirs(fn)
|
|
|
|
result = []
|
|
|
|
Rake.each_dir_parent(fn) { |d| result << d }
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_can_override_application
|
|
|
|
old_app = Rake.application
|
|
|
|
fake_app = Object.new
|
|
|
|
Rake.application = fake_app
|
2011-06-24 02:11:55 +04:00
|
|
|
|
2009-10-02 23:07:55 +04:00
|
|
|
assert_equal fake_app, Rake.application
|
2011-06-24 02:11:55 +04:00
|
|
|
|
2009-10-02 23:07:55 +04:00
|
|
|
ensure
|
|
|
|
Rake.application = old_app
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_original_dir_reports_current_dir
|
2011-06-24 02:11:55 +04:00
|
|
|
assert_equal @tempdir, Rake.original_dir
|
2009-10-02 23:07:55 +04:00
|
|
|
end
|
2011-05-15 15:55:52 +04:00
|
|
|
|
2009-10-02 23:07:55 +04:00
|
|
|
end
|