Sha256: f6d2d7cdc92ecf50dfea0eb74313b2b4387539a4ef481a5b63cdb6380e26b1bf

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

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

class TestXMLText < Test::Unit::TestCase
  # Test a simple mapping with no composition
  def test_valid_simple
    book = Book.from_xml(fixture(:book_valid))
    assert_equal("The PickAxe", book.title)
  end

  def test_without_needed_from
    assert !Library.from_xml(fixture(:library_uppercase)).name
  end

  def test_with_needed_from
    assert_equal "Ruby library", Library.from_xml(fixture(:library)).name
    assert_equal "Ruby library", UppercaseLibrary.from_xml(fixture(:library_uppercase)).name
  end

  def test_as_array
    assert_equal ["David Thomas","Andrew Hunt","Dave Thomas"].sort,
                 BookWithAuthors.from_xml(fixture(:book_with_authors)).authors.sort
  end

  def test_text_modification
    person = Person.from_xml(fixture(:person))
    assert_equal("Ben Franklin", person.name)
    person.name = "Fred"
    xml=person.to_xml.to_s
    assert(/Fred/=~xml)
  end

  def test_default_initialization
    person = PersonWithMotherOrMissing.from_xml(fixture(:nameless_ageless_youth))
    assert_equal "Anonymous", person.name
  end

  def test_default_initialization_of_content
    person = Person.from_xml(fixture(:nameless_ageless_youth))
    assert_equal "Unknown", person.name
  end

  def test_recursive_with_default_initialization
    p = PersonWithMotherOrMissing.from_xml(fixture(:person_with_mothers))
    assert_equal 'Unknown', p.mother.mother.mother.name
  end

  def test_get_with_block
    p = Book.from_xml(fixture(:book_valid))
    assert_equal 357, p.pages
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Empact-roxml-2.2 test/unit/xml_text_test.rb