Sha256: 77fb3e45c1f840381982ef720a5fcffc84ddf07f7cf7163b92a0c033d0a3b439

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

require 'test/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

8 entries across 8 versions & 3 rubygems

Version Path
yob-roxml-3.1.6 test/unit/xml_attribute_test.rb
roxml-3.1.5 test/unit/xml_attribute_test.rb
roxml-3.1.4 test/unit/xml_attribute_test.rb
roxml-3.1.3 test/unit/xml_attribute_test.rb
roxml-3.1.2 test/unit/xml_attribute_test.rb
roxml-3.1.1 test/unit/xml_attribute_test.rb
roxml-3.1.0 test/unit/xml_attribute_test.rb
ROXML-3.0.0 test/unit/xml_attribute_test.rb