Sha256: 7e78e01aa5002b0a13c5ec78461b18e5bd0dbaf7a9559296db624cf6e2e7c422

Contents?: true

Size: 1.7 KB

Versions: 2

Compression:

Stored size: 1.7 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.parse(fixture(:book_valid))
    assert_equal("The PickAxe", book.title)
  end

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

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

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

  def test_text_modification
    person = Person.parse(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.parse(fixture(:nameless_ageless_youth))
    assert_equal "Anonymous", person.name
  end

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Empact-roxml-2.0 test/unit/xml_text_test.rb
Empact-roxml-2.1 test/unit/xml_text_test.rb