Sha256: 4cf42f11f11e119bc950d14ae0758692c8127323d0f59072c9f337e5b69bd21f

Contents?: true

Size: 1012 Bytes

Versions: 22

Compression:

Stored size: 1012 Bytes

Contents

require File.expand_path(::File.dirname(__FILE__) + '/../lib/xml/smart')
require File.expand_path(::File.dirname(__FILE__) + '/smartrunner.rb')

class TestToDoc < Minitest::Test
  def test_todoc
    doc = XML::Smart.open(::File.dirname(__FILE__) + "/EXAMPLE-NS.xml")
    doc.root.children[0].add('soap:haller')
    doc.register_namespace :d, 'http://example.org'

    nums = 10000

    assert(doc.find("/d:test/d:names").first.to_doc.root.namespaces.length == 2)
    assert(doc.find("/d:test/d:names/d:name[2]").first.to_doc.root.namespaces.length == 1)
    assert(doc.find("/d:test").first.to_doc.root.namespaces.length == 2)

    # Watch the power
    Minitest::PerformanceReporter::start_timing "#to_doc (#{nums} times)"
    nums.times do
      doc.find("/d:test/d:names/d:name[2]").first.to_doc
    end  
    Minitest::PerformanceReporter::end_timing
     
    assert(doc.find("/d:test/d:names/d:name[2]").first.to_doc.root.dump == '<name xmlns="http://example.org" team="1">J&#xFC;rgen</name>')
  end
end  

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
xml-smart-0.5.3 test/tc_todoc.rb
xml-smart-0.5.2 test/tc_todoc.rb
xml-smart-0.5.1 test/tc_todoc.rb
xml-smart-0.5.0 test/tc_todoc.rb
xml-smart-0.4.4 test/tc_todoc.rb
xml-smart-0.4.3 test/tc_todoc.rb
xml-smart-0.4.2 test/tc_todoc.rb
xml-smart-0.4.1 test/tc_todoc.rb
xml-smart-0.4.0 test/tc_todoc.rb
xml-smart-0.3.22 test/tc_todoc.rb
xml-smart-0.3.21 test/tc_todoc.rb
xml-smart-0.3.20 test/tc_todoc.rb
xml-smart-0.3.19 test/tc_todoc.rb
xml-smart-0.3.18 test/tc_todoc.rb
xml-smart-0.3.17 test/tc_todoc.rb
xml-smart-0.3.16 test/tc_todoc.rb
xml-smart-0.3.15 test/tc_todoc.rb
xml-smart-0.3.14 test/tc_todoc.rb
xml-smart-0.3.12 test/tc_todoc.rb
xml-smart-0.3.11 test/tc_todoc.rb