Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cfis committed Jan 8, 2024
1 parent b0d1f07 commit cf6f478
Showing 1 changed file with 58 additions and 60 deletions.
118 changes: 58 additions & 60 deletions test/test_namespace.rb
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
# encoding: UTF-8

require_relative './test_helper'


class TestNS < Minitest::Test
def setup
file = File.join(File.dirname(__FILE__), 'model/soap.xml')
@doc = LibXML::XML::Document.file(file)
end

def teardown
@doc = nil
end

def test_create_ns
node = LibXML::XML::Node.new('foo')
ns = LibXML::XML::Namespace.new(node, 'my_namepace', 'http://www.mynamespace.com')
assert_equal(ns.prefix, 'my_namepace')
assert_equal(ns.href, 'http://www.mynamespace.com')
end

def test_create_default_ns
node = LibXML::XML::Node.new('foo')
ns = LibXML::XML::Namespace.new(node, nil, 'http://www.mynamespace.com')
assert_nil(ns.prefix)
assert_equal(ns.href, 'http://www.mynamespace.com')
end

def test_create_unbound_ns
error = assert_raises(TypeError) do
LibXML::XML::Namespace.new(nil, 'my_namepace', 'http://www.mynamespace.com')
end
assert_equal('wrong argument type nil (expected Data)', error.to_s)
end

def test_duplicate_ns
node = LibXML::XML::Node.new('foo')
LibXML::XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
assert_raises(LibXML::XML::Error) do
LibXML::XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
end
end

def test_eql
node = LibXML::XML::Node.new('Envelope')

assert(node.namespaces.namespace.eql?(node.namespaces.namespace))
end

def test_equal
node1 = LibXML::XML::Node.new('Envelope')
ns1 = LibXML::XML::Namespace.new(node1, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')

node2 = LibXML::XML::Node.new('Envelope')
ns2 = LibXML::XML::Namespace.new(node2, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')

assert(ns1 == ns2)
end
end
# encoding: UTF-8

require_relative './test_helper'


class TestNS < Minitest::Test
def setup
file = File.join(File.dirname(__FILE__), 'model/soap.xml')
@doc = LibXML::XML::Document.file(file)
end

def teardown
@doc = nil
end

def test_create_ns
node = LibXML::XML::Node.new('foo')
ns = LibXML::XML::Namespace.new(node, 'my_namepace', 'http://www.mynamespace.com')
assert_equal(ns.prefix, 'my_namepace')
assert_equal(ns.href, 'http://www.mynamespace.com')
end

def test_create_default_ns
node = LibXML::XML::Node.new('foo')
ns = LibXML::XML::Namespace.new(node, nil, 'http://www.mynamespace.com')
assert_nil(ns.prefix)
assert_equal(ns.href, 'http://www.mynamespace.com')
end

def test_create_unbound_ns
error = assert_raises(TypeError) do
LibXML::XML::Namespace.new(nil, 'my_namepace', 'http://www.mynamespace.com')
end
assert_equal('wrong argument type nil (expected Data)', error.to_s)
end

def test_duplicate_ns
node = LibXML::XML::Node.new('foo')
LibXML::XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
LibXML::XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
end

def test_eql
node = LibXML::XML::Node.new('Envelope')

assert(node.namespaces.namespace.eql?(node.namespaces.namespace))
end

def test_equal
node1 = LibXML::XML::Node.new('Envelope')
ns1 = LibXML::XML::Namespace.new(node1, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')

node2 = LibXML::XML::Node.new('Envelope')
ns2 = LibXML::XML::Namespace.new(node2, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')

assert(ns1 == ns2)
end
end

0 comments on commit cf6f478

Please sign in to comment.