diff options
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 |