File: test_soap4r_sax.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 (55 lines) | stat: -rw-r--r-- 1,052 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
# frozen_string_literal: true

require "helper"

module XSD
  module XMLParser
    class Parser
      @factory_added = nil

      class << self; attr_reader :factory_added; end

      def self.add_factory(o)
        @factory_added = o
      end

      def initialize(*args)
        @charset = nil
      end

      def characters(foo)
      end

      def start_element(*args)
      end

      def end_element(*args)
      end
    end
  end
end

require "xsd/xmlparser/nokogiri"

class TestSoap4rSax < Nokogiri::TestCase
  def test_factory_added
    assert_equal(XSD::XMLParser::Nokogiri, XSD::XMLParser::Nokogiri.factory_added)
  end

  def test_parse
    o = Class.new(::XSD::XMLParser::Nokogiri) do
      attr_accessor :element_started

      def initialize(*args)
        super
        @element_started = false
      end

      def start_element(*args)
        @element_started = true
      end
    end.new("foo")
    o.do_parse('<?xml version="1.0" ?><root xmlns="http://example.com/"/>')
    assert(o.element_started, "element started")
  end
end