ruby-changes:2164
From: ko1@a...
Date: 7 Oct 2007 22:43:09 +0900
Subject: [ruby-changes:2164] kou - Ruby:r13655 (trunk): * test/rss/test_taxonomy.rb, test/rss/test_parser_1.0.rb,
kou 2007-10-07 22:42:22 +0900 (Sun, 07 Oct 2007) New Revision: 13655 Modified files: trunk/ChangeLog trunk/test/rss/rss-testcase.rb trunk/test/rss/test_image.rb trunk/test/rss/test_parser_1.0.rb trunk/test/rss/test_taxonomy.rb Log: * test/rss/test_taxonomy.rb, test/rss/test_parser_1.0.rb, test/rss/test_image.rb, test/rss/rss-testcase.rb: ensured declaring XML namespaces. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/test_parser_1.0.rb?r1=13655&r2=13654 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/rss-testcase.rb?r1=13655&r2=13654 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13655&r2=13654 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/test_taxonomy.rb?r1=13655&r2=13654 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/rss/test_image.rb?r1=13655&r2=13654 Index: ChangeLog =================================================================== --- ChangeLog (revision 13654) +++ ChangeLog (revision 13655) @@ -1,3 +1,9 @@ +Sun Oct 7 22:37:47 2007 Kouhei Sutou <kou@c...> + + * test/rss/test_taxonomy.rb, test/rss/test_parser_1.0.rb, + test/rss/test_image.rb, test/rss/rss-testcase.rb: ensured + declaring XML namespaces. + Sun Oct 7 22:00:01 2007 Tanaka Akira <akr@f...> * include/ruby/node.h: make node flags as VALUE type. Index: test/rss/rss-testcase.rb =================================================================== --- test/rss/rss-testcase.rb (revision 13654) +++ test/rss/rss-testcase.rb (revision 13655) @@ -332,7 +332,14 @@ "<#{h elem_name} #{attrs_str}>\n#{contents_str}\n</#{h elem_name}>" end - + + def xmlns_container(xmlns_decls, content) + attributes = xmlns_decls.collect do |prefix, uri| + "xmlns:#{h prefix}=\"#{h uri}\"" + end.join(" ") + "<dummy #{attributes}>#{content}</dummy>" + end + private def setup_rss10(rdf) assert_equal("", rdf.to_s) Index: test/rss/test_taxonomy.rb =================================================================== --- test/rss/test_taxonomy.rb (revision 13654) +++ test/rss/test_taxonomy.rb (revision 13655) @@ -144,8 +144,10 @@ end @topic_nodes.each_with_index do |node, i| - expected = REXML::Document.new(node).root - actual = REXML::Document.new(@rss.taxo_topics[i].to_s(true, "")).root + expected_xml = taxo_xmlns_container(node) + expected = REXML::Document.new(expected_xml).root.elements[1] + actual_xml = taxo_xmlns_container(@rss.taxo_topics[i].to_s(true, "")) + actual = REXML::Document.new(actual_xml).root.elements[1] expected_elems = expected.reject {|x| x.is_a?(REXML::Text)} actual_elems = actual.reject {|x| x.is_a?(REXML::Text)} expected_elems.sort! {|x, y| x.name <=> y.name} @@ -155,6 +157,16 @@ assert_equal(expected.attributes.sort, actual.attributes.sort) end end + + private + def taxo_xmlns_container(content) + xmlns_container({ + @prefix => @uri, + "dc" => "http://purl.org/dc/elements/1.1/", + "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + }, + content) + end end end Index: test/rss/test_image.rb =================================================================== --- test/rss/test_image.rb (revision 13654) +++ test/rss/test_image.rb (revision 13655) @@ -173,19 +173,23 @@ def test_favicon_to_s favicon = @rss.channel.image_favicon - expected = REXML::Document.new(make_element("#{@prefix}:favicon", - @favicon_attrs, - @favicon_contents)) - actual = REXML::Document.new(favicon.to_s(false, "")) + expected_xml = image_xmlns_container(make_element("#{@prefix}:favicon", + @favicon_attrs, + @favicon_contents)) + expected = REXML::Document.new(expected_xml) + actual_xml = image_xmlns_container(favicon.to_s(false, "")) + actual = REXML::Document.new(actual_xml) assert_equal(expected.to_s, actual.to_s) end def test_item_to_s @rss.items.each_with_index do |item, i| attrs, contents = @items[i] - expected_s = make_element("#{@prefix}:item", attrs, contents) - expected = REXML::Document.new(expected_s) - actual = REXML::Document.new(item.image_item.to_s(false, "")) + expected_xml = make_element("#{@prefix}:item", attrs, contents) + expected_xml = image_xmlns_container(expected_xml) + expected = REXML::Document.new(expected_xml) + actual_xml = image_xmlns_container(item.image_item.to_s(false, "")) + actual = REXML::Document.new(actual_xml) assert_equal(expected[0].attributes, actual[0].attributes) @@ -197,5 +201,14 @@ end end + private + def image_xmlns_container(content) + xmlns_container({ + @prefix => @uri, + "dc" => "http://purl.org/dc/elements/1.1/", + "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + }, + content) + end end end Index: test/rss/test_parser_1.0.rb =================================================================== --- test/rss/test_parser_1.0.rb (revision 13654) +++ test/rss/test_parser_1.0.rb (revision 13655) @@ -500,7 +500,8 @@ end def test_unknown_duplicated_element - assert_parse(make_RDF(<<-EOR), :nothing_raised) + xmlns = {"test" => "http://localhost/test"} + assert_parse(make_RDF(<<-EOR, xmlns), :nothing_raised) #{make_channel("<test:string/>")} #{make_item} #{make_image} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml