Sha256: 2a6f22656d2f7e99770b5d63e3e6c16b22a14abb179e676f220d65bd5a5f827e

Contents?: true

Size: 729 Bytes

Versions: 2

Compression:

Stored size: 729 Bytes

Contents

require "test/unit"
require "marc"

class BadXMLHandlingTestCase < Test::Unit::TestCase
  def test_nokogiri_bad_xml
    begin
      require "nokogiri"
    rescue LoadError
      omit("nokogiri not installed, cannot test")
    end
    omit("nokogiri (<1.10.2) under jruby doesn't support error handling: sparklemotion/nokogiri#1847") if RUBY_PLATFORM == "java" && Gem::Version.new(Nokogiri::VERSION) < Gem::Version.new("1.10.2")
    count = 0
    reader = MARC::XMLReader.new("test/three-records-second-bad.xml", parser: :nokogiri)
    assert_raise MARC::XMLParseError do
      reader.each do |rec|
        count += 1 if rec["260"]
      end
    end
    assert_equal(1, count, "should only be able to parse one record")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
marc-1.3.0 test/tc_xml_error_handling.rb
marc-1.2.0 test/tc_xml_error_handling.rb