Sha256: e5b130e1832bbb7c26286ad665628142a9bd03eb98bc688a50efa2080a06b401

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

require_relative 'test_helper'
require 'splunk-sdk-ruby'

include Splunk

class TestXMLShim < Test::Unit::TestCase
  def test_escape_string_with_rexml
    Splunk::require_xml_library(:rexml)
    assert_equal("&lt;&gt;'\"&amp;", Splunk::escape_string("<>'\"&"))
  end

  def test_escape_string_with_nokogiri
    Splunk::require_xml_library(:nokogiri)
    assert_equal("&lt;&gt;'\"&amp;", Splunk::escape_string("<>'\"&"))
  end

  def test_no_matches_with_rexml
    Splunk::require_xml_library(:rexml)
    assert_nil(Splunk::text_at_xpath("//msg", "<html>Hi</html>"))
  end

  def test_no_matches_with_nokogiri
    Splunk::require_xml_library(:nokogiri)
    assert_nil(Splunk::text_at_xpath("//msg", "<html>Hi</html>"))
  end

  def test_matches_with_nokogiri
    Splunk::require_xml_library(:nokogiri)
    m = Splunk::text_at_xpath("//msg", "<response><msg>Boris &amp; Natasha</msg></response>")
    assert_equal("Boris & Natasha", m)
  end

  def test_matches_with_rexml
    Splunk::require_xml_library(:rexml)
    m = Splunk::text_at_xpath("//msg", "<response><msg>Boris &amp; Natasha</msg></response>")
    assert_equal("Boris & Natasha", m)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
splunk-sdk-ruby-1.0.5 test/test_xml_shim.rb
splunk-sdk-ruby-1.0.4 test/test_xml_shim.rb
splunk-sdk-ruby-1.0.3 test/test_xml_shim.rb
splunk-sdk-ruby-1.0.2 test/test_xml_shim.rb
splunk-sdk-ruby-1.0.1 test/test_xml_shim.rb
splunk-sdk-ruby-1.0.0 test/test_xml_shim.rb
splunk-sdk-ruby-0.8.1 test/test_xml_shim.rb