1# frozen_string_literal: false
2require 'test/unit'
3require 'rexml/document'
4
5module REXMLTests
6  class TestAttributes < Test::Unit::TestCase
7    def setup
8      @ns_a = "urn:x-test:a"
9      @ns_b = "urn:x-test:b"
10      element_string = <<-"XMLEND"
11      <test xmlns:a="#{@ns_a}"
12            xmlns:b="#{@ns_b}"
13            a = "1"
14            b = '2'
15            a:c = "3"
16            a:d = '4'
17            a:e = "5"
18            b:f = "6"/>
19      XMLEND
20      @attributes = REXML::Document.new(element_string).root.attributes
21    end
22
23    def test_get_attribute_ns
24      assert_equal("1", @attributes.get_attribute_ns("", "a").value)
25      assert_equal("2", @attributes.get_attribute_ns("", "b").value)
26      assert_equal("3", @attributes.get_attribute_ns(@ns_a, "c").value)
27      assert_equal("4", @attributes.get_attribute_ns(@ns_a, "d").value)
28      assert_equal("5", @attributes.get_attribute_ns(@ns_a, "e").value)
29      assert_equal("6", @attributes.get_attribute_ns(@ns_b, "f").value)
30    end
31  end
32end
33