1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
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
|