File: test_errors.rb

package info (click to toggle)
ruby-nokogiri 1.18.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 8,076 kB
  • sloc: ansic: 38,893; xml: 27,665; ruby: 27,285; java: 15,348; cpp: 7,107; yacc: 244; sh: 208; makefile: 154; sed: 14
file content (20 lines) | stat: -rw-r--r-- 679 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# encoding: utf-8
# frozen_string_literal: true

require "helper"

if Nokogiri.uses_gumbo?
  class TestHtml5Serialize < Nokogiri::TestCase
    def test_nonstandard_elements_in_errors
      doc = Nokogiri::HTML5.fragment("<table><foo></foo></table>", max_errors: 100)
      assert_equal(2, doc.errors.length)
      assert_match(/Start tag 'foo'/, doc.errors.first.to_s.lines.first)
    end

    def test_nonstandard_elements_in_tag_stack
      doc = Nokogiri::HTML5.fragment("<foo><table><br></table></foo>", max_errors: 100)
      assert_equal(1, doc.errors.length)
      assert_match(/Currently open tags: html, foo, table/, doc.errors.first.to_s.lines.first)
    end
  end
end