diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-11 01:34:28 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-11 01:34:28 +0000 |
commit | ff5366a7053a2d420139e32fb3936ee85a2839fe (patch) | |
tree | 4d499b33305a640e0d054a5018b6416477a10580 /test/rdoc/test_rdoc_rdoc.rb | |
parent | 48a68756f5813a078d3c69a4180a9102208f953b (diff) |
Update to RDoc 2.5.3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc/test_rdoc_rdoc.rb')
-rw-r--r-- | test/rdoc/test_rdoc_rdoc.rb | 91 |
1 files changed, 90 insertions, 1 deletions
diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index 7c8f7778d8..772ba4c3b1 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -1,4 +1,5 @@ require 'tempfile' +require 'tmpdir' require 'rubygems' require 'minitest/autorun' require 'rdoc/rdoc' @@ -11,7 +12,7 @@ class TestRDocRDoc < MiniTest::Unit::TestCase end def teardown - @tempfile.close + @tempfile.close rescue nil # HACK for 1.8.6 end def test_gather_files @@ -19,6 +20,24 @@ class TestRDocRDoc < MiniTest::Unit::TestCase assert_equal [file], @rdoc.gather_files([file, file]) end + def test_normalized_file_list + files = @rdoc.normalized_file_list [__FILE__] + + files = files.map { |file| File.expand_path file } + + assert_equal [File.expand_path(__FILE__)], files + end + + def test_normalized_file_list_not_modified + files = [__FILE__] + + @rdoc.last_modified[__FILE__] = File.stat(__FILE__).mtime + + files = @rdoc.normalized_file_list [__FILE__] + + assert_empty files + end + def test_read_file_contents @tempfile.write "hi everybody" @tempfile.flush @@ -62,5 +81,75 @@ class TestRDocRDoc < MiniTest::Unit::TestCase assert_empty @rdoc.remove_unparseable file_list end + def test_setup_output_dir + path = @tempfile.path + @tempfile.unlink + + last = @rdoc.setup_output_dir path, false + + assert_empty last + + assert File.directory? path + ensure + FileUtils.rm_f path + end + + def test_setup_output_dir_exists + path = @tempfile.path + @tempfile.unlink + FileUtils.mkdir_p path + + open @rdoc.output_flag_file(path), 'w' do |io| + io.puts Time.at 0 + io.puts "./lib/rdoc.rb\t#{Time.at 86400}" + end + + last = @rdoc.setup_output_dir path, false + + assert_equal 1, last.size + assert_equal Time.at(86400), last['./lib/rdoc.rb'] + ensure + FileUtils.rm_f path + end + + def test_setup_output_dir_exists_empty_created_rid + path = @tempfile.path + @tempfile.unlink + FileUtils.mkdir_p path + + open @rdoc.output_flag_file(path), 'w' do end + + e = assert_raises RDoc::Error do + @rdoc.setup_output_dir path, false + end + + assert_match %r%Directory #{Regexp.escape path} already exists%, e.message + ensure + FileUtils.rm_f path + end + + def test_setup_output_dir_exists_file + path = @tempfile.path + + e = assert_raises RDoc::Error do + @rdoc.setup_output_dir path, false + end + + assert_match(%r%#{Regexp.escape path} exists and is not a directory%, + e.message) + end + + def test_setup_output_dir_exists_not_rdoc + skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir + + Dir.mktmpdir do |dir| + e = assert_raises RDoc::Error do + @rdoc.setup_output_dir dir, false + end + + assert_match %r%Directory #{Regexp.escape dir} already exists%, e.message + end + end + end |