File: test_nokogumbo_contract.rb

package info (click to toggle)
ruby-nokogiri 1.13.10%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,416 kB
  • sloc: ansic: 38,198; xml: 28,086; ruby: 22,271; java: 15,517; cpp: 7,037; yacc: 244; sh: 148; makefile: 136
file content (28 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download
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
# frozen_string_literal: true

require "helper"

describe "Nokogumbo contract expectations" do
  # per https://github.com/rubys/nokogumbo/pull/171
  it "includes the HTML5 public interface" do
    skip("Gumbo is not supported on this platform") unless Nokogiri.uses_gumbo?

    assert_includes(::Nokogiri.singleton_methods, :HTML5)

    assert_equal("constant", defined?(::Nokogiri::HTML5))
    assert_includes(::Nokogiri::HTML5.singleton_methods, :parse)
    assert_includes(::Nokogiri::HTML5.singleton_methods, :fragment)

    assert_equal("constant", defined?(::Nokogiri::HTML5::Node))
    assert_equal("constant", defined?(::Nokogiri::HTML5::Document))
    assert_equal("constant", defined?(::Nokogiri::HTML5::DocumentFragment))
  end

  it "includes a replacement for the Nokogumbo private interface" do
    skip("Gumbo is not supported on this platform") unless Nokogiri.uses_gumbo?

    assert_equal("constant", defined?(::Nokogiri::Gumbo))
    assert_includes(::Nokogiri::Gumbo.singleton_methods, :parse)
    assert_includes(::Nokogiri::Gumbo.singleton_methods, :fragment)
  end
end