rootdir = File.dirname(File.dirname(__FILE__)) $LOAD_PATH.unshift "#{rootdir}/lib" require 'test/unit' require 'rdiscount' class RDiscountTest < Test::Unit::TestCase def test_that_discount_does_not_blow_up_with_weird_formatting_case text = (<<-TEXT).gsub(/^ {4}/, '').rstrip 1. some text 1. TEXT RDiscount.new(text).to_html end def test_that_smart_converts_double_quotes_to_curly_quotes rd = RDiscount.new(%("Quoted text"), :smart) assert_equal %(

“Quoted text”

\n), rd.to_html end def test_that_smart_converts_double_quotes_to_curly_quotes_before_a_heading rd = RDiscount.new(%("Quoted text"\n\n# Heading), :smart) assert_equal %(

“Quoted text”

\n\n

Heading

\n), rd.to_html end def test_that_smart_converts_double_quotes_to_curly_quotes_after_a_heading rd = RDiscount.new(%(# Heading\n\n"Quoted text"), :smart) assert_equal %(

Heading

\n\n

“Quoted text”

\n), rd.to_html end def test_that_generate_toc_sets_toc_ids rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc) assert rd.generate_toc assert_equal %(

Level 1

\n\n

Level 2

\n), rd.to_html end def test_should_get_the_generated_toc rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc) exp = %() assert_equal exp, rd.toc_content.strip end end