Sha256: eabc6724c82cd9c17f2a5f5bf2c790ac7881f3b341a8ec57bc15f0537ddd0862

Contents?: true

Size: 825 Bytes

Versions: 12

Compression:

Stored size: 825 Bytes

Contents

require "xml"
require 'test/unit'

class TestXPathExpression < Test::Unit::TestCase
  def setup
    xp = XML::Parser.new()
    str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
    xp.string = str
    @doc = xp.parse
  end
  
  def teardown
    @doc = nil
  end

  def nodes
    expr = XML::XPath::Expression.compile('/ruby_array/fixnum')
    @doc.find(expr)
  end

  def test_find_class
    expr = XML::XPath::Expression.new('/ruby_array/fixnum')
    set = @doc.find(expr)
    assert_instance_of(XML::XPath::Object, set)
    assert_equal(2, set.size)
  end

  def test_find_invalid
    error = assert_raise(TypeError) do
      set = @doc.find(999)
    end
    assert_equal('Argument should be an intance of a String or XPath::Expression',
                 error.to_s)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
libxml-ruby-0.9.3-x86-mswin32-60 test/tc_xpath_expression.rb
libxml-ruby-0.9.2-x86-mswin32-60 test/tc_xpath_expression.rb
libxml-ruby-0.9.2 test/tc_xpath_expression.rb
libxml-ruby-0.9.3 test/tc_xpath_expression.rb
libxml-ruby-0.9.6 test/tc_xpath_expression.rb
libxml-ruby-0.9.5 test/tc_xpath_expression.rb
libxml-ruby-0.9.5-x86-mswin32-60 test/tc_xpath_expression.rb
libxml-ruby-0.9.6-x86-mswin32-60 test/tc_xpath_expression.rb
libxml-ruby-0.9.4 test/tc_xpath_expression.rb
libxml-ruby-0.9.4-x86-mswin32-60 test/tc_xpath_expression.rb
libxml-ruby-0.9.7 test/tc_xpath_expression.rb
libxml-ruby-0.9.7-x86-mswin32-60 test/tc_xpath_expression.rb