require "helper" class IntegrationTestHelpers < Loofah::TestCase context ".strip_tags" do context "on safe markup" do it "strip out tags" do assert_equal "omgwtfbbq!!1!", Loofah::Helpers.strip_tags("
omgwtfbbq
!!1!") end end context "on hack attack" do it "strip escape html entities" do bad_shit = "<script>alert('evil')</script>" assert_equal bad_shit, Loofah::Helpers.strip_tags(bad_shit) end end end context ".sanitize" do context "on safe markup" do it "render the safe html" do html = "
omgwtfbbq
!!1!" assert_equal html, Loofah::Helpers.sanitize(html) end end context "on hack attack" do it "strip the unsafe tags" do assert_equal "alert('evil')w00t", Loofah::Helpers.sanitize("w00t") end it "strips form tags" do assert_equal "alert('evil')w00t", Loofah::Helpers.sanitize("
w00t") end end end context ".sanitize_css" do it "removes unsafe css properties" do assert_match(/display:\s*block;\s*background-color:\s*blue;/, Loofah::Helpers.sanitize_css("display:block;background-image:url(http://www.ragingplatypus.com/i/cam-full.jpg);background-color:blue")) end end end