Sha256: 85105f1fedee5fbfd455e16e05208f0f6f7f9b81e7fc7f14298c42b3bd6fca4e
Contents?: true
Size: 892 Bytes
Versions: 26
Compression:
Stored size: 892 Bytes
Contents
# Run from your Rails main directory require 'test/test_helper' class TestERB < Test::Unit::TestCase def assert_renders_erb(expected, input, shield=true) erb_class = shield ? XSSProtectedERB : ERB actual = eval(erb_class.new(input).src) assert_equal expected, actual end def test_erb_with_shield assert_renders_erb <<OUT, <<IN, true Foo &amp; Bar Foo &amp; Bar Foo & Bar Foo & Bar Foo & Bar OUT <%= "Foo & Bar" %> <%= h("Foo & Bar") %> <%= "Foo & Bar".mark_as_xss_protected %> <%= h("Foo & Bar") %> <%= "Foo & Bar" %> IN end def test_erb_without_shield assert_renders_erb <<OUT, <<IN, false Foo &amp; Bar Foo & Bar Foo & Bar Foo & Bar Foo & Bar OUT <%= h("Foo & Bar") %> <%= "Foo & Bar" %> <%= "Foo & Bar".mark_as_xss_protected %> <%= h("Foo & Bar") %> <%= "Foo & Bar" %> IN end end
Version data entries
26 entries across 26 versions & 5 rubygems