Sha256: 7212525ba244cfdad16e884716655eda377aa6bfff83197ef56dcb90a29f2d0c

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

require_relative './../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

7 entries across 7 versions & 2 rubygems

Version Path
roxml-3.3.1 test/unit/xml_attribute_test.rb
roxml-3.3.0 test/unit/xml_attribute_test.rb
roxml-3.2.2 test/unit/xml_attribute_test.rb
roxml-3.2.1 test/unit/xml_attribute_test.rb
roxml-3.2.0 test/unit/xml_attribute_test.rb
representable-0.0.1.alpha1 test/unit/xml_attribute_test.rb
roxml-3.1.6 test/unit/xml_attribute_test.rb