Sha256: 95131f3f10d5c1ee5d80a2ab8b99b032c48cd9960748c5fcfa07b1a7cae49ea7

Contents?: true

Size: 1.78 KB

Versions: 60

Compression:

Stored size: 1.78 KB

Contents

require "helper"

class IntegrationTestXml < Loofah::TestCase
  context "integration test" do
    context "xml document" do
      context "custom scrubber" do
        it "act as expected" do
          xml = Loofah.xml_document <<-EOXML
            <root>
              <employee deceased='true'>Abraham Lincoln</employee>
              <employee deceased='false'>Abe Vigoda</employee>
            </root>
          EOXML
          bring_out_your_dead = Loofah::Scrubber.new do |node|
            if node.name == "employee" and node["deceased"] == "true"
              node.remove
              Loofah::Scrubber::STOP # don't bother with the rest of the subtree
            end
          end
          assert_equal 2, xml.css("employee").length
          
          xml.scrub!(bring_out_your_dead)

          employees = xml.css "employee"
          assert_equal 1, employees.length
          assert_equal "Abe Vigoda", employees.first.inner_text
        end
      end
    end

    context "xml fragment" do
      context "custom scrubber" do
        it "act as expected" do
          xml = Loofah.xml_fragment <<-EOXML
            <employee deceased='true'>Abraham Lincoln</employee>
            <employee deceased='false'>Abe Vigoda</employee>
          EOXML
          bring_out_your_dead = Loofah::Scrubber.new do |node|
            if node.name == "employee" and node["deceased"] == "true"
              node.remove
              Loofah::Scrubber::STOP # don't bother with the rest of the subtree
            end
          end
          assert_equal 2, xml.css("employee").length
          
          xml.scrub!(bring_out_your_dead)

          employees = xml.css "employee"
          assert_equal 1, employees.length
          assert_equal "Abe Vigoda", employees.first.inner_text
        end
      end
    end
  end
end

Version data entries

60 entries across 52 versions & 14 rubygems

Version Path
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/loofah-2.2.3/test/integration/test_xml.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/loofah-2.2.3/test/integration/test_xml.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/loofah-2.2.3/test/integration/test_xml.rb
spiral_form-0.1.1 vendor/bundle/gems/loofah-2.2.3/test/integration/test_xml.rb
spiral_form-0.1.0 vendor/bundle/gems/loofah-2.2.3/test/integration/test_xml.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/loofah-2.2.3/test/integration/test_xml.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/loofah-2.2.3/test/integration/test_xml.rb
loofah-2.2.3 test/integration/test_xml.rb
loofah-2.2.2 test/integration/test_xml.rb
loofah-2.2.1 test/integration/test_xml.rb
loofah-2.2.0 test/integration/test_xml.rb
loofah-2.1.1 test/integration/test_xml.rb
loofah-2.1.0 test/integration/test_xml.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/loofah-2.0.3/test/integration/test_xml.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_xml.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_xml.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_xml.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_xml.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_xml.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/loofah-2.0.3/test/integration/test_xml.rb