diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-20 03:22:49 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-20 03:22:49 +0000 |
commit | 2ef9c50c6e405717d06362787c4549ca4f1c6485 (patch) | |
tree | ee99486567461dd5796f3d6edcc9e204187f2666 /test/rdoc/test_rdoc_rdoc.rb | |
parent | d7effd506f5b91a636f2e6452ef1946b923007c7 (diff) | |
download | ruby-2ef9c50c6e405717d06362787c4549ca4f1c6485.tar.gz |
Import RDoc 3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc/test_rdoc_rdoc.rb')
-rw-r--r-- | test/rdoc/test_rdoc_rdoc.rb | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index b02ef2ae1a..d65e2f3427 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -1,15 +1,21 @@ -require 'tempfile' -require 'tmpdir' require 'rubygems' require 'minitest/autorun' require 'rdoc/rdoc' +require 'fileutils' +require 'tempfile' +require 'tmpdir' + class TestRDocRDoc < MiniTest::Unit::TestCase def setup @rdoc = RDoc::RDoc.new + @rdoc.options = RDoc::Options.new + + @stats = RDoc::Stats.new 0, 0 + @rdoc.instance_variable_set :@stats, @stats + @tempfile = Tempfile.new 'test_rdoc_rdoc' - @tempfile.binmode end def teardown @@ -39,48 +45,6 @@ class TestRDocRDoc < MiniTest::Unit::TestCase assert_empty files end - def test_read_file_contents - @tempfile.write "hi everybody" - @tempfile.flush - - assert_equal "hi everybody", @rdoc.read_file_contents(@tempfile.path) - end - - def test_read_file_contents_encoding - skip "Encoding not implemented" unless defined? ::Encoding - - @tempfile.write "# coding: utf-8\nhi everybody" - @tempfile.flush - - contents = @rdoc.read_file_contents @tempfile.path - assert_equal "# coding: utf-8\nhi everybody", contents - assert_equal Encoding::UTF_8, contents.encoding - end - - def test_read_file_contents_encoding_fancy - skip "Encoding not implemented" unless defined? ::Encoding - - @tempfile.write "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody" - @tempfile.flush - - contents = @rdoc.read_file_contents @tempfile.path - assert_equal("# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody", - contents) - assert_equal Encoding::UTF_8, contents.encoding - end - - def test_read_file_contents_encoding_with_signature - skip "Encoding not implemented" unless defined? ::Encoding - - @tempfile.write "\xEF\xBB\xBF""hi everybody" - @tempfile.flush - - bug3360 = '[ruby-dev:41452]' - contents = @rdoc.read_file_contents @tempfile.path - assert_equal "hi everybody", contents, bug3360 - assert_equal Encoding::UTF_8, contents.encoding, bug3360 - end - def test_remove_unparsable file_list = %w[ blah.class @@ -108,6 +72,20 @@ class TestRDocRDoc < MiniTest::Unit::TestCase } end + def test_setup_output_dir_dry_run + skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir + + @rdoc.options.dry_run = true + + Dir.mktmpdir do |d| + path = File.join d, 'testdir' + + @rdoc.setup_output_dir path, false + + refute File.exist? path + end + end + def test_setup_output_dir_exists skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir @@ -161,5 +139,26 @@ class TestRDocRDoc < MiniTest::Unit::TestCase end end + def test_update_output_dir + skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir + + Dir.mktmpdir do |d| + @rdoc.update_output_dir d, Time.now, {} + + assert File.exist? "#{d}/created.rid" + end + end + + def test_update_output_dir_dry_run + skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir + + Dir.mktmpdir do |d| + @rdoc.options.dry_run = true + @rdoc.update_output_dir d, Time.now, {} + + refute File.exist? "#{d}/created.rid" + end + end + end |