require File.expand_path(File.join(File.dirname(__FILE__), 'helper')) if defined? Nokogiri::VERSION_INFO puts "=> running with Nokogiri #{Nokogiri::VERSION_INFO.inspect}" else puts "=> running with Nokogiri #{Nokogiri::VERSION} / libxml #{Nokogiri::LIBXML_PARSER_VERSION}" end class TestBasic < Test::Unit::TestCase MSWORD_HTML = <<-EOHTML
Foo BOLD
This fragment is in a p.
", Dryopteris.sanitize("This fragment is in a p.
") end def test_fragment_in_a_nontrivial_p_tag assert_equal " \nThis fragment is in a p.
", Dryopteris.sanitize(" \nThis fragment is in a p.
") end def test_fragment_in_p_tag_plus_stuff assert_equal "This fragment is in a p.
foobar", Dryopteris.sanitize("This fragment is in a p.
foobar") end def test_fragment_with_text_nodes_leading_and_trailing assert_equal "textfragment
text", Dryopteris.sanitize("textfragment
text") end def test_whitewash_on_fragment html = "safe description" whitewashed = Dryopteris.whitewash_document(html) assert_equal "safe
description", whitewashed end def test_whitewash_fragment_on_microsofty_markup whitewashed = Dryopteris.whitewash(MSWORD_HTML.chomp) assert_equal "Foo BOLD
", whitewashed end def test_whitewash_on_microsofty_markup whitewashed = Dryopteris.whitewash_document(MSWORD_HTML) assert_equal "Foo BOLD
", whitewashed end end