Sha256: 11b35c05d29622ab90009bff3def7b7d815545a08df0f066846b669b064ccf84

Contents?: true

Size: 1.9 KB

Versions: 397

Compression:

Stored size: 1.9 KB

Contents

require "helper"

module Nokogiri
  module XML
    class TestAttributeDecl < Nokogiri::TestCase
      def setup
        super
        @xml = Nokogiri::XML(<<-eoxml)
<?xml version="1.0"?><?TEST-STYLE PIDATA?>
<!DOCTYPE staff SYSTEM "staff.dtd" [
   <!ATTLIST br width CDATA "0">
   <!ATTLIST a width CDATA "0">
   <!ATTLIST payment type (check|cash) "cash">
]>
<root />
        eoxml
        @attrs = @xml.internal_subset.children
        @attr_decl = @attrs.first
      end

      def test_inspect
        assert_equal(
          "#<#{@attr_decl.class.name}:#{sprintf("0x%x", @attr_decl.object_id)} #{@attr_decl.to_s.inspect}>",
          @attr_decl.inspect
        )
      end

      def test_type
        assert_equal 16, @attr_decl.type
      end

      def test_class
        assert_instance_of Nokogiri::XML::AttributeDecl, @attr_decl
      end

      def test_content
        assert_raise NoMethodError do
          @attr_decl.content
        end
      end

      def test_attributes
        assert_raise NoMethodError do
          @attr_decl.attributes
        end
      end

      def test_namespace
        assert_raise NoMethodError do
          @attr_decl.namespace
        end
      end

      def test_namespace_definitions
        assert_raise NoMethodError do
          @attr_decl.namespace_definitions
        end
      end

      def test_line
        assert_raise NoMethodError do
          @attr_decl.line
        end
      end

      def test_attribute_type
        if Nokogiri.uses_libxml?
          assert_equal 1, @attr_decl.attribute_type
        else
          assert_equal 'CDATA', @attr_decl.attribute_type
        end
      end

      def test_default
        assert_equal '0', @attr_decl.default
        assert_equal '0', @attrs[1].default
      end

      def test_enumeration
        assert_equal [], @attr_decl.enumeration
        assert_equal ['check', 'cash'], @attrs[2].enumeration
      end
    end
  end
end

Version data entries

397 entries across 387 versions & 35 rubygems

Version Path
tdiary-5.0.11 vendor/bundle/gems/nokogiri-1.8.5/test/xml/test_attribute_decl.rb
tdiary-5.0.11 vendor/bundle/gems/nokogiri-1.8.4/test/xml/test_attribute_decl.rb
nokogiri-1.9.0.rc1 test/xml/test_attribute_decl.rb
nokogiri-1.9.0.rc1-x86-mingw32 test/xml/test_attribute_decl.rb
nokogiri-1.9.0.rc1-x64-mingw32 test/xml/test_attribute_decl.rb
nokogiri-1.9.0.rc1-java test/xml/test_attribute_decl.rb
nokogiri-1.8.5 test/xml/test_attribute_decl.rb
nokogiri-1.8.5-x86-mingw32 test/xml/test_attribute_decl.rb
nokogiri-1.8.5-x64-mingw32 test/xml/test_attribute_decl.rb
nokogiri-1.8.5-java test/xml/test_attribute_decl.rb
daslabs-0.12.0 vendor/cache/ruby/2.5.0/gems/nokogiri-1.8.2/test/xml/test_attribute_decl.rb
daslabs-0.11.0 vendor/cache/ruby/2.5.0/gems/nokogiri-1.8.2/test/xml/test_attribute_decl.rb
nokogiri-1.8.4 test/xml/test_attribute_decl.rb
nokogiri-1.8.4-x86-mingw32 test/xml/test_attribute_decl.rb
nokogiri-1.8.4-x64-mingw32 test/xml/test_attribute_decl.rb
nokogiri-1.8.4-java test/xml/test_attribute_decl.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.3/test/xml/test_attribute_decl.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.3/test/xml/test_attribute_decl.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/nokogiri-1.8.3/test/xml/test_attribute_decl.rb
tdiary-5.0.9 vendor/bundle/gems/nokogiri-1.8.2/test/xml/test_attribute_decl.rb