require 'rdoc/test_case' class TestAttributeManager < RDoc::TestCase # HACK fix test name def setup super @options = RDoc::Options.new @am = RDoc::Markup::AttributeManager.new @klass = RDoc::Markup::AttributeManager @formatter = RDoc::Markup::Formatter.new @options @formatter.add_tag :BOLD, '', '' @formatter.add_tag :EM, '', '' @formatter.add_tag :TT, '', '' end def test_convert_attrs_ignores_code assert_equal 'foo __send__ bar', output('foo __send__ bar') end def test_convert_attrs_ignores_tt assert_equal 'foo __send__ bar', output('foo __send__ bar') end def test_convert_attrs_preserves_double assert_equal 'foo.__send__ :bar', output('foo.__send__ :bar') assert_equal 'use __FILE__ to', output('use __FILE__ to') end def test_convert_attrs_does_not_ignore_after_tt assert_equal 'the IF:key directive', output('the IF:_key_ directive') end def test_initial_word_pairs word_pairs = @am.matching_word_pairs assert word_pairs.is_a?(Hash) assert_equal(3, word_pairs.size) end def test_initial_html html_tags = @am.html_tags assert html_tags.is_a?(Hash) assert_equal(5, html_tags.size) end def test_add_matching_word_pair @am.add_word_pair("x","x", :TEST) word_pairs = @am.matching_word_pairs assert_equal(4,word_pairs.size) assert(word_pairs.has_key?("x")) end def test_add_invalid_word_pair assert_raises ArgumentError do @am.add_word_pair("<", "<", :TEST) end end def test_add_word_pair_map @am.add_word_pair("x", "y", :TEST) word_pair_map = @am.word_pair_map assert_equal(1,word_pair_map.size) assert_equal(word_pair_map. keys.first.source, "(x)(\\S+)(y)") end def test_add_html_tag @am.add_html("Test", :TEST) tags = @am.html_tags assert_equal(6, tags.size) assert(tags.has_key?("test")) end def test_add_special @am.add_special "WikiWord", :WIKIWORD specials = @am.special assert_equal 1, specials.size assert specials.assoc "WikiWord" end def test_escapes assert_equal 'text', output('text') assert_equal 'text', output('\\text') assert_equal '', output('\\') assert_equal '', output('\\') assert_equal '\\', output('\\\\') assert_equal 'text', output('*text*') assert_equal '*text*', output('\\*text*') assert_equal '\\', output('\\') assert_equal '\\text', output('\\text') assert_equal '\\\\text', output('\\\\text') assert_equal 'text \\ text', output('text \\ text') assert_equal 'and \\s matches space', output('and \\s matches space') assert_equal 'use text for code', output('use \\text for code') assert_equal 'use text for code', output('use \\text\\ for code') assert_equal 'use text for code', output('use \\\\text for code') assert_equal 'use text for code', output('use \\text for code') assert_equal 'use +text+ for code', output('use \\+text+ for code') assert_equal 'use text for code', output('use \\+text+ for code') assert_equal 'illegal not changed', output('illegal not changed') assert_equal 'unhandled

tag

unchanged', output('unhandled

tag

unchanged') end def output str @formatter.convert_flow @am.flow str end end