Sha256: 1fdf99bc2722fbdca375cbf164e79d0b948ee36c20f67b874980143d9449436f

Contents?: true

Size: 733 Bytes

Versions: 4

Compression:

Stored size: 733 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

4 entries across 4 versions & 1 rubygems

Version Path
marc-1.1.1 test/tc_xml_error_handling.rb
marc-1.1.0 test/tc_xml_error_handling.rb
marc-1.0.4 test/tc_xml_error_handling.rb
marc-1.0.3 test/tc_xml_error_handling.rb