Sha256: 187649945d5be3988ebab28f44ab01e2b22a28e9662cc23bc0f7b9181bfeb2c0

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'htmlentities'
require 'test/unit'

$KCODE = 'u'

#
# 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

2 entries across 2 versions & 2 rubygems

Version Path
htmlentities-4.0.0 test/legacy_test.rb
typo-5.3 vendor/gems/htmlentities-4.0.0/test/legacy_test.rb