File: tc_properties.rb

package info (click to toggle)
ruby-libxml 2.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,812 kB
  • sloc: xml: 9,628; ruby: 7,119; ansic: 6,665; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,006 bytes parent folder | download | duplicates (2)
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
# encoding: UTF-8

require './test_helper'

require 'test/unit'

# attributes is deprecated - use attributes instead.
# Tests for backwards compatibility

class Testattributes < Test::Unit::TestCase
  def setup()
    xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
    @doc = xp.parse
  end

  def teardown()
    @doc = nil
  end

  def test_traversal
    attributes = @doc.root.attributes
    
    assert_instance_of(XML::Attributes, attributes)
    attribute = attributes.first
    assert_equal('uga', attribute.name)
    assert_equal('booga', attribute.value)

    attribute = attribute.next
    assert_instance_of(XML::Attr, attribute)
    assert_equal('foo', attribute.name)
    assert_equal('bar', attribute.value)
  end
  
  def test_no_attributes
    attributes = @doc.root.child.attributes
    assert_instance_of(XML::Attributes, attributes)
    assert_equal(0, attributes.length)
  end
end