Sha256: b21117691a2be2a16b96d73d4511ffe5304ccf941d0417b2be886acad342e587

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

require File.join(File.dirname(__FILE__), '..', 'test_helper')

class TestXMLAttribute < ActiveSupport::TestCase
  def test_attr_from
    # :attr => *
    book = Book.from_xml(fixture(:book_text_with_attribute))
    assert_equal '0201710897', book.isbn

    # :attr, :from => *
    book = BookWithAttrFrom.from_xml(fixture(:book_text_with_attribute))
    assert_equal '0201710897', book.isbn
  end

  def test_mutable_attr
    book = Book.from_xml(fixture(:book_text_with_attribute))
    assert book.respond_to?(:'isbn=')
  end

  def test_default_initialization
    person = PersonWithMotherOrMissing.from_xml(fixture(:nameless_ageless_youth))
    assert_equal 21, person.age
  end

  def test_recursive_with_default_initialization
    p = PersonWithMotherOrMissing.from_xml(fixture(:person_with_mothers))
    assert_equal 21, p.mother.mother.mother.age
  end

  def test_no_name_clashes
    n = NodeWithAttrNameConflicts.from_xml(fixture(:node_with_attr_name_conflicts))
    assert_equal "Just junk... really", n.content
    assert_equal "Cartwheel", n.name
  end

  def test_wrapped_attr_accessible
    b = BookWithWrappedAttr.from_xml(fixture(:book_with_wrapped_attr))
    assert_equal "0974514055", b.isbn
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
Empact-roxml-2.5.2 test/unit/xml_attribute_test.rb
Empact-roxml-2.5.3 test/unit/xml_attribute_test.rb
doxo-roxml-2.5.3 test/unit/xml_attribute_test.rb
roxml-2.5.3 test/unit/xml_attribute_test.rb
roxml-2.5.2 test/unit/xml_attribute_test.rb