Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

TDD: write test of escape_html renderer option

  • Loading branch information...
commit a87389b7cad43cca742d10943be395bbc63e44d3 1 parent bdf09d4
chitsaou authored vmg committed
Showing with 23 additions and 0 deletions.
  1. +23 −0 test/redcarpet_test.rb
View
23 test/redcarpet_test.rb
@@ -60,6 +60,7 @@ def setup
:no_images => Redcarpet::Render::HTML.new(:no_images => true),
:no_links => Redcarpet::Render::HTML.new(:no_links => true),
:safe_links => Redcarpet::Render::HTML.new(:safe_links_only => true),
+ :escape_html => Redcarpet::Render::HTML.new(:escape_html => true),
}
end
@@ -67,6 +68,28 @@ def render_with(rndr, text)
Redcarpet::Markdown.new(rndr).render(text)
end
+ # Hint: overrides filter_html, no_images and no_links
+ def test_that_escape_html_works
+ source = <<EOS
+Through <em>NO</em> <script>DOUBLE NO</script>
+
+<script>BAD</script>
+
+<img src="/favicon.ico" />
+EOS
+ expected = <<EOE
+<p>Through &lt;em&gt;NO&lt;/em&gt; &lt;script&gt;DOUBLE NO&lt;/script&gt;</p>
+
+<p>&lt;script&gt;BAD&lt;/script&gt;</p>
+
+<p>&lt;img src=&quot;/favicon.ico&quot; /&gt;
+
+EOE
+
+ markdown = render_with(@rndr[:escape_html], source)
+ html_equal expected, markdown
+ end
+
def test_that_filter_html_works
markdown = render_with(@rndr[:no_html], 'Through <em>NO</em> <script>DOUBLE NO</script>')
html_equal "<p>Through NO DOUBLE NO</p>", markdown
Please sign in to comment.
Something went wrong with that request. Please try again.