# File test/core_test.rb, line 33 def test_attribute # Testing constructors a = Attribute.new "hello", "dolly" b = Attribute.new a source = SourceFactory.create_from "hello='dolly' href='blah'" c = Attribute.new source assert_equals a, b for attr in [ a, b, c] assert_equals "hello", attr.name assert_equals "dolly", attr.value end assert_equals source.buffer.strip, "href='blah'" # This because of a reported bug in attribute handling in 1.0a8 source = '<a att="A">blah</a>' doc = Document.new source doc.elements.each do |a| a.attributes['att'] << 'B' assert_equal "AB", a.attributes['att'] a.attributes['att'] = 'C' assert_equal "C", a.attributes['att'] end # Bryan Murphy <murphybryanp@yahoo.com> text = "this is a {target[@name='test']/@value} test" source = "\t\t<?xml version=\"1.0\"?>\n\t\t<doc search=\"\#{text}\"/>\n" xml = Document.new source value = xml.root.attributes["search"] assert_equal text, value.to_s e = Element.new "test" e.add_attributes({ "name1" => "test1", "name2" => "test2" }) e.add_attributes([["name3","test3"], ["name4","test4"]]) assert_equal "test1", e.attributes["name1"] assert_equal "test2", e.attributes["name2"] assert_equal "test3", e.attributes["name3"] assert_equal "test4", e.attributes["name4"] end