Sha256: fa179db10a11f4a54ecddee9123215215c41b3cdb9a9082756879afbe0dd20d7

Contents?: true

Size: 1.99 KB

Versions: 28

Compression:

Stored size: 1.99 KB

Contents

require "helper"

module Nokogiri
  module XML
    class TestDTD < Nokogiri::TestCase
      def setup
        super
        @xml = Nokogiri::XML(File.open(XML_FILE))
        assert @dtd = @xml.internal_subset
      end

      def test_system_id
        assert_equal 'staff.dtd', @dtd.system_id
      end

      def test_external_id
        xml = Nokogiri::XML('<!DOCTYPE foo PUBLIC "bar" ><foo />')
        assert dtd = xml.internal_subset
        assert_equal 'bar', dtd.external_id
      end

      def test_content
        assert_raise NoMethodError do
          @dtd.content
        end
      end

      def test_attributes
        assert_equal ['width'], @dtd.attributes.keys
        assert_equal '0', @dtd.attributes['width'].default
      end

      def test_namespace
        assert_raise NoMethodError do
          @dtd.namespace
        end
      end

      def test_namespace_definitions
        assert_raise NoMethodError do
          @dtd.namespace_definitions
        end
      end

      def test_line
        assert_raise NoMethodError do
          @dtd.line
        end
      end

      def test_validate
        list = @xml.internal_subset.validate @xml
        assert_equal 44, list.length
      end

      def test_external_subsets
        assert subset = @xml.internal_subset
        assert_equal 'staff', subset.name
      end

      def test_entities
        assert entities = @dtd.entities
        assert_equal %w[ ent1 ent2 ent3 ent4 ent5 ].sort, entities.keys.sort
      end

      def test_elements
        assert elements = @dtd.elements
        assert_equal %w[ br ], elements.keys
        assert_equal 'br', elements['br'].name
      end

      def test_notations
        assert notations = @dtd.notations
        assert_equal %w[ notation1 notation2 ].sort, notations.keys.sort
        assert notation1 = notations['notation1']
        assert_equal 'notation1', notation1.name
        assert_equal 'notation1File', notation1.public_id
        assert_nil notation1.system_id
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 6 rubygems

Version Path
nokogiri-1.4.3.1-java test/xml/test_dtd.rb
nokogiri-1.4.3.1-x86-mswin32 test/xml/test_dtd.rb
nokogiri-1.4.3.1-x86-mingw32 test/xml/test_dtd.rb
nokogiri-1.4.3.1 test/xml/test_dtd.rb
nokogiri-1.4.3-java test/xml/test_dtd.rb
nokogiri-1.4.3-x86-mswin32 test/xml/test_dtd.rb
nokogiri-1.4.3-x86-mingw32 test/xml/test_dtd.rb
nokogiri-1.4.3 test/xml/test_dtd.rb
glebm-nokogiri-1.4.2.1 test/xml/test_dtd.rb
nokogiri-1.4.2.1-x86-mswin32 test/xml/test_dtd.rb
nokogiri-1.4.2.1-x86-mingw32 test/xml/test_dtd.rb
nokogiri-1.4.2-java test/xml/test_dtd.rb
nokogiri-1.4.2 test/xml/test_dtd.rb
jwagener-nokogiri-1.4.1 test/xml/test_dtd.rb
revo-nokogiri-1.4.1-java test/xml/test_dtd.rb
revo-nokogiri-1.4.0.3-java test/xml/test_dtd.rb
revo-nokogiri-1.4.0-java test/xml/test_dtd.rb
revo-nokogiri-1.4.0.20100202165440-java test/xml/test_dtd.rb
nokogiri-1.4.1-x86-mswin32 test/xml/test_dtd.rb
nokogiri-1.4.1-x86-mingw32 test/xml/test_dtd.rb