File: test_class_resolver.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 (56 lines) | stat: -rw-r--r-- 1,549 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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true

require "helper"

describe Nokogiri::ClassResolver do
  describe Nokogiri::XML::Node do
    it "finds the right things" do
      assert_equal(
        Nokogiri::XML::DocumentFragment,
        Nokogiri::XML::Document.new.related_class("DocumentFragment"),
      )
      assert_equal(
        Nokogiri::HTML4::DocumentFragment,
        Nokogiri::HTML4::Document.new.related_class("DocumentFragment"),
      )
      if defined?(Nokogiri::HTML5)
        assert_equal(
          Nokogiri::HTML5::DocumentFragment,
          Nokogiri::HTML5::Document.new.related_class("DocumentFragment"),
        )
      end
    end
  end

  describe Nokogiri::XML::Builder do
    it "finds the right things" do
      assert_equal(
        Nokogiri::XML::Document,
        Nokogiri::XML::Builder.new.related_class("Document"),
      )
      assert_equal(
        Nokogiri::HTML4::Document,
        Nokogiri::HTML4::Builder.new.related_class("Document"),
      )
      if defined?(Nokogiri::HTML5)
        assert_equal(
          Nokogiri::HTML5::Document,
          Nokogiri::HTML5::Builder.new.related_class("Document"),
        )
      end
    end
  end

  describe Nokogiri::XML::SAX::Parser do
    it "finds the right things" do
      assert_equal(
        Nokogiri::XML::SAX::ParserContext,
        Nokogiri::XML::SAX::Parser.new.related_class("ParserContext"),
      )
      assert_equal(
        Nokogiri::HTML4::SAX::ParserContext,
        Nokogiri::HTML4::SAX::Parser.new.related_class("ParserContext"),
      )
    end
  end
end