Sha256: 164d8d635f9307583b6345876effd66069b665b653ce1604f36e92941ca11576

Contents?: true

Size: 939 Bytes

Versions: 7

Compression:

Stored size: 939 Bytes

Contents

# encoding: UTF-8
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'test/unit'
require 'htmlentities'

$KCODE = 'u' unless "1.9".respond_to?(:encoding)

#
# Test that version 3.x functionality still works
#
class HTMLEntities::LegacyTest < Test::Unit::TestCase

  def test_should_decode_via_legacy_interface
    assert_decode('&', '&amp;')
    assert_decode('±', '&plusmn;')
    assert_decode('“', '&#8220;')
    assert_decode('—', '&#x2014;')
  end

  def test_should_encode_via_legacy_interface
    assert_encode('&amp;', '&', :basic)
    assert_encode('&eth;', 'ð', :named)
    assert_encode('&#8230;', '…', :decimal)
    assert_encode('&#x2212;', '−', :hexadecimal)
  end

  def assert_encode(expected, *encode_args)
    assert_equal expected, HTMLEntities.encode_entities(*encode_args)
  end

  def assert_decode(expected, *decode_args)
    assert_equal expected, HTMLEntities.decode_entities(*decode_args)
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
htmlentities-4.2.4 test/legacy_test.rb
htmlentities-4.2.3 test/legacy_test.rb
htmlentities-4.2.2 test/legacy_test.rb
htmlentitties-4.2.1 test/legacy_test.rb
htmlentities-4.2.1 test/legacy_test.rb
htmlentities-4.2.0 test/legacy_test.rb
htmlentities-4.1.0 test/legacy_test.rb