diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-21 12:19:43 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-21 12:19:43 +0000 |
commit | 57a639494a2a002f496a945979e2bf499b0d9fdb (patch) | |
tree | 53fadfc1666459e1286735a37171539883d66d70 /test/rss/test_image.rb | |
parent | 754b1fac44487454cc25a14443615c0fba3da6ad (diff) |
* lib/rss.rb, lib/rss/, test/rss/, sample/rss/: merged from trunk.
- 0.1.6 -> 2.0.0.
- fixed image module URI. Thanks to Dmitry Borodaenko.
- supported Atom.
- supported ITunes module.
- supported Slash module.
* NEWS: added an entry for RSS Parser.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rss/test_image.rb')
-rw-r--r-- | test/rss/test_image.rb | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/test/rss/test_image.rb b/test/rss/test_image.rb index 241fdafb7d..101b7ffda2 100644 --- a/test/rss/test_image.rb +++ b/test/rss/test_image.rb @@ -11,7 +11,7 @@ module RSS def setup @prefix = "image" - @uri = "http://web.resource.org/rss/1.0/modules/image/" + @uri = "http://purl.org/rss/1.0/modules/image/" @favicon_attrs = { "rdf:about" => "http://www.kuro5hin.org/favicon.ico", @@ -65,20 +65,30 @@ EOR @rss = Parser.parse(@rss_source) end - + def test_parser assert_nothing_raised do Parser.parse(@rss_source) end - + assert_too_much_tag("favicon", "channel") do Parser.parse(make_RDF(<<-EOR, @ns)) #{make_channel(@channel_nodes * 2)} #{make_item} EOR end + + attrs = {"rdf:about" => "http://www.example.org/item.png"} + contents = [["#{@prefix}:width", "80"]] * 5 + image_item = make_element("#{@prefix}:item", attrs, contents) + assert_too_much_tag("width", "item") do + Parser.parse(make_RDF(<<-EOR, @ns)) +#{make_channel} +#{make_item(image_item)} +EOR + end end - + def test_favicon_accessor favicon = @rss.channel.image_favicon [ @@ -135,7 +145,7 @@ EOR image_item.__send__("#{name}=", attrs[full_name]) assert_equal(attrs[full_name], image_item.__send__(name)) end - + [ ["width", "image:width", "111"], ["image_width", "image:width", "44"], @@ -163,22 +173,26 @@ EOR 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) - + %w(image:height image:width dc:title).each do |name| actual_target = actual.elements["//#{name}"] expected_target = expected.elements["//#{name}"] @@ -187,5 +201,14 @@ EOR 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 |