From 1e760c0be3ed35874204114e7454509f740c0fe2 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Wed, 22 Aug 2007 01:53:51 +0000 Subject: add tag v1_8_6_71 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_5_71@13189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby_1_8_6/test/rss/test_parser_2.0.rb | 122 +++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 ruby_1_8_6/test/rss/test_parser_2.0.rb (limited to 'ruby_1_8_6/test/rss/test_parser_2.0.rb') diff --git a/ruby_1_8_6/test/rss/test_parser_2.0.rb b/ruby_1_8_6/test/rss/test_parser_2.0.rb new file mode 100644 index 0000000000..249347d3dc --- /dev/null +++ b/ruby_1_8_6/test/rss/test_parser_2.0.rb @@ -0,0 +1,122 @@ +require "rss-testcase" + +require "rss/2.0" + +module RSS + class TestParser20 < TestCase + def test_rss20 + assert_parse(make_rss20(<<-EOR), :missing_tag, "channel", "rss") +EOR + + assert_parse(make_rss20(<<-EOR), :nothing_raised) +#{make_channel20("")} +EOR + end + + def test_cloud20 + attrs = [ + ["domain", CLOUD_DOMAIN], + ["port", CLOUD_PORT], + ["path", CLOUD_PATH], + ["registerProcedure", CLOUD_REGISTER_PROCEDURE], + ["protocol", CLOUD_PROTOCOL], + ] + + (attrs.size + 1).times do |i| + missing_attr = attrs[i] + if missing_attr + meth = :missing_attribute + args = ["cloud", missing_attr[0]] + else + meth = :nothing_raised + args = [] + end + + cloud_attrs = [] + attrs.each_with_index do |attr, j| + unless i == j + cloud_attrs << %Q[#{attr[0]}="#{attr[1]}"] + end + end + + assert_parse(make_rss20(<<-EOR), meth, *args) +#{make_channel20(%Q[])} +EOR + end + end + + def test_source20 + assert_parse(make_rss20(<<-EOR), :missing_attribute, "source", "url") +#{make_channel20(make_item20(%Q[Example]))} +EOR + + assert_parse(make_rss20(<<-EOR), :nothing_raised) +#{make_channel20(make_item20(%Q[]))} +EOR + + assert_parse(make_rss20(<<-EOR), :nothing_raised) +#{make_channel20(make_item20(%Q[Example]))} +EOR + end + + def test_enclosure20 + attrs = [ + ["url", ENCLOSURE_URL], + ["length", ENCLOSURE_LENGTH], + ["type", ENCLOSURE_TYPE], + ] + + (attrs.size + 1).times do |i| + missing_attr = attrs[i] + if missing_attr + meth = :missing_attribute + args = ["enclosure", missing_attr[0]] + else + meth = :nothing_raised + args = [] + end + + enclosure_attrs = [] + attrs.each_with_index do |attr, j| + unless i == j + enclosure_attrs << %Q[#{attr[0]}="#{attr[1]}"] + end + end + + assert_parse(make_rss20(<<-EOR), meth, *args) +#{make_channel20(%Q[ +#{make_item20(%Q[ + + ])} + ])} +EOR + end + end + + def test_category20 + values = [nil, CATEGORY_DOMAIN] + values.each do |value| + domain = "" + domain << %Q[domain="#{value}"] if value + + ["", "Example Text"].each do |text| + rss_src = make_rss20(<<-EOR) +#{make_channel20(%Q[ +#{make_item20(%Q[ +#{text} + ])} + ])} +EOR + assert_parse(rss_src, :nothing_raised) + + rss = RSS::Parser.parse(rss_src) + category = rss.items.last.categories.first + assert_equal(value, category.domain) + assert_equal(text, category.content) + end + end + end + end +end + -- cgit v1.2.3