Guest User

Untitled

a guest
Apr 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. require File.dirname(__FILE__) + '/../test_helper'
  2.  
  3. class StathamSanitizerTest < ActiveSupport::TestCase
  4. context "A StathamSanitizer" do
  5. setup do
  6. @sanitizer = HTML::StathamSanitizer.new
  7. end
  8.  
  9. should "escape tags that are neither allowed nor banned" do
  10. assert_equal "<font>Hello</font>", @sanitizer.sanitize("<font>Hello</font>")
  11. end
  12.  
  13. should "escape tags that are allowed but unclosed" do
  14. assert_equal "<p>Hello", @sanitizer.sanitize("<p>Hello")
  15. end
  16.  
  17. should "escape tags that are closed without ever being opened" do
  18. assert_equal "Hello</p>", @sanitizer.sanitize("Hello</p>")
  19. end
  20.  
  21. should "include tags that are allowed and self-closing" do
  22. assert_equal "Hello<br />", @sanitizer.sanitize("Hello<br />")
  23. end
  24.  
  25. should "escape comments" do
  26. assert_equal "<!-- comment", @sanitizer.sanitize("<!-- comment")
  27. end
  28. end
  29. end
Add Comment
Please, Sign In to add comment