diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-27 04:28:14 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-27 04:28:14 +0000 |
commit | 1c279a7d2753949c725754e1302f791b76358114 (patch) | |
tree | 36aa3bdde250e564445eba5f2e25fcb96bcb6cef /test/rdoc/test_rdoc_markup_pre_process.rb | |
parent | c72f0daa877808e4fa5018b3191ca09d4b97c03d (diff) | |
download | ruby-1c279a7d2753949c725754e1302f791b76358114.tar.gz |
* lib/rdoc*: Updated to RDoc 4.0 (pre-release)
* bin/rdoc: ditto
* test/rdoc: ditto
* NEWS: Updated with RDoc 4.0 information
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc/test_rdoc_markup_pre_process.rb')
-rw-r--r-- | test/rdoc/test_rdoc_markup_pre_process.rb | 69 |
1 files changed, 60 insertions, 9 deletions
diff --git a/test/rdoc/test_rdoc_markup_pre_process.rb b/test/rdoc/test_rdoc_markup_pre_process.rb index 34867c8c6b..3a991a6397 100644 --- a/test/rdoc/test_rdoc_markup_pre_process.rb +++ b/test/rdoc/test_rdoc_markup_pre_process.rb @@ -1,16 +1,11 @@ # coding: utf-8 -require 'tempfile' -require 'rubygems' -require 'minitest/autorun' -require 'rdoc/markup/pre_process' -require 'rdoc/code_objects' -require 'rdoc/options' +require 'rdoc/test_case' -class TestRDocMarkupPreProcess < MiniTest::Unit::TestCase +class TestRDocMarkupPreProcess < RDoc::TestCase def setup - RDoc::Markup::PreProcess.registered.clear + super @tempfile = Tempfile.new 'test_rdoc_markup_pre_process' @file_name = File.basename @tempfile.path @@ -20,11 +15,23 @@ class TestRDocMarkupPreProcess < MiniTest::Unit::TestCase end def teardown - RDoc::Markup::PreProcess.registered.clear + super @tempfile.close end + def test_class_register + RDoc::Markup::PreProcess.register 'for_test' do raise 'fail' end + + assert_equal %w[for_test], RDoc::Markup::PreProcess.registered.keys + end + + def test_class_post_process + RDoc::Markup::PreProcess.post_process do end + + assert_equal 1, RDoc::Markup::PreProcess.post_processors.length + end + def test_include_file @tempfile.write <<-INCLUDE # -*- mode: rdoc; coding: utf-8; fill-column: 74; -*- @@ -73,6 +80,50 @@ contents of a string. assert_equal "#\n", text end + def test_handle_comment + text = "# :main: M\n" + c = comment text + + out = @pp.handle c + + assert_same out, text + assert_equal "#\n", text + end + + def test_handle_markup + c = comment ':markup: rd' + + @pp.handle c + + assert_equal 'rd', c.format + end + + def test_handle_markup_empty + c = comment ':markup:' + + @pp.handle c + + assert_equal 'rdoc', c.format + end + + def test_handle_post_process + cd = RDoc::CodeObject.new + + RDoc::Markup::PreProcess.post_process do |text, code_object| + code_object.metadata[:stuff] = text + + :junk + end + + text = "# a b c\n" + + out = @pp.handle text, cd + + assert_same out, text + assert_equal "# a b c\n", text + assert_equal "# a b c\n", cd.metadata[:stuff] + end + def test_handle_unregistered text = "# :x: y\n" out = @pp.handle text |