Sha256: cf31f209cf0277bd62ab0050985d4fa7d387b1cfdd349609d1969c092dc4108b

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8
require File.expand_path("../../helper", __FILE__)

class HtmlUnescapeTest < Minitest::Test
  def test_basic_html
    assert_equal "<some_tag/>", EscapeUtils.unescape_html("&lt;some_tag&#47;&gt;")
  end

  def test_double_quotes
    assert_equal "<some_tag some_attr=\"some value\"/>", EscapeUtils.unescape_html("&lt;some_tag some_attr=&quot;some value&quot;&#47;&gt;")
  end

  def test_single_quotes
    assert_equal "<some_tag some_attr='some value'/>", EscapeUtils.unescape_html("&lt;some_tag some_attr=&#39;some value&#39;&#47;&gt;")
  end

  def test_amperstand
    assert_equal "<b>Bourbon & Branch</b>", EscapeUtils.unescape_html("&lt;b&gt;Bourbon &amp; Branch&lt;&#47;b&gt;")
  end

  def test_passes_through_incompletely_escaped_tags
    assert_equal "&", EscapeUtils.unescape_html("&")
    assert_equal "&lt", EscapeUtils.unescape_html("&lt")
  end

  def test_return_value_is_tagged_as_utf8
    escaped = EscapeUtils.escape_html("<b>Bourbon & Branch</b>")
    assert_equal Encoding.find('UTF-8'), EscapeUtils.unescape_html(escaped).encoding
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
escape_utils-1.3.0 test/html/unescape_test.rb