Skip to content

Commit

Permalink
adding some sample specs to try to determine how we should handle edg…
Browse files Browse the repository at this point in the history
…e cases for fragments.
  • Loading branch information
flavorjones committed Feb 10, 2009
1 parent 886887b commit d0f0b6b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/test_basic.rb
Expand Up @@ -10,10 +10,6 @@ def test_empty_string
assert_equal "", Dryopteris.sanitize("") assert_equal "", Dryopteris.sanitize("")
end end


# def test_preserve_whitespace
# assert_equal "<b>Foo</b>\n<i>Bar</i>", Dryopteris.sanitize("<b>Foo</b>\n<i>Bar</i>")
# end

def test_removal_of_illegal_tag def test_removal_of_illegal_tag
html = <<-HTML html = <<-HTML
following this there should be no jim tag following this there should be no jim tag
Expand Down Expand Up @@ -51,4 +47,16 @@ def test_css_sanitization
assert_no_match(/foo\.com/, sane.inner_html) assert_no_match(/foo\.com/, sane.inner_html)
end end


def test_fragment_with_no_tags
assert_equal "This fragment has no tags.", Dryopteris.sanitize("This fragment has no tags.")
end

def test_fragment_in_p_tag
assert_equal "<p>This fragment is in a p.</p>", Dryopteris.sanitize("<p>This fragment is in a p.</p>")
end

def test_fragment_in_a_nontrivial_p_tag
assert_equal "<p>This fragment is in a p.</p>", Dryopteris.sanitize(" \n<p foo='bar'>This fragment is in a p.</p>")
end

end end

0 comments on commit d0f0b6b

Please sign in to comment.