summaryrefslogtreecommitdiff
path: root/test/rss/test_2.0.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-17 10:13:25 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-17 10:13:25 +0000
commit966a25465aab5c2972e6c453f631a15fc2223256 (patch)
tree847090e856c9901ab2cc19251c179b9b0985e65b /test/rss/test_2.0.rb
parent53cbab048452742b537ac8bccf494630d1c184c8 (diff)
* lib/rss, test/rss:
- supported Atom. - bumped version 0.1.6 to 0.1.7. * sample/rss/convert.rb: added new sample. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rss/test_2.0.rb')
-rw-r--r--test/rss/test_2.0.rb54
1 files changed, 35 insertions, 19 deletions
diff --git a/test/rss/test_2.0.rb b/test/rss/test_2.0.rb
index 2027e5344a..5a63efbcb9 100644
--- a/test/rss/test_2.0.rb
+++ b/test/rss/test_2.0.rb
@@ -2,8 +2,6 @@ require "rexml/document"
require "rss-testcase"
-require "rss/2.0"
-
module RSS
class TestRSS20Core < TestCase
@@ -17,6 +15,7 @@ module RSS
standalone = false
rss = Rss.new(@rss_version, version, encoding, standalone)
+ setup_rss20(rss)
doc = REXML::Document.new(rss.to_s(false))
@@ -48,7 +47,9 @@ module RSS
{:href => "a.css", :type => "text/css"},
],
].each do |attrs_ary|
- assert_xml_stylesheet_pis(attrs_ary, Rss.new(@rss_version))
+ rss = Rss.new(@rss_version)
+ setup_rss20(rss)
+ assert_xml_stylesheet_pis(attrs_ary, rss)
end
end
@@ -253,6 +254,10 @@ module RSS
pubDate = Time.parse("Sat, 07 Sep 2002 00:00:01 GMT")
channel = Rss::Channel.new
+ channel.title = "title"
+ channel.link = "http://example.com/"
+ channel.description = "description"
+
item = Rss::Channel::Item.new
channel.items << item
@@ -373,22 +378,33 @@ module RSS
end
assert_equal(source_params, actual)
end
-
- def test_indent_size
- assert_equal(0, Rss.indent_size)
- assert_equal(1, Rss::Channel.indent_size)
- assert_equal(2, Rss::Channel::SkipDays.indent_size)
- assert_equal(3, Rss::Channel::SkipDays::Day.indent_size)
- assert_equal(2, Rss::Channel::SkipHours.indent_size)
- assert_equal(3, Rss::Channel::SkipHours::Hour.indent_size)
- assert_equal(2, Rss::Channel::Image.indent_size)
- assert_equal(2, Rss::Channel::Cloud.indent_size)
- assert_equal(2, Rss::Channel::Item.indent_size)
- assert_equal(3, Rss::Channel::Item::Source.indent_size)
- assert_equal(3, Rss::Channel::Item::Enclosure.indent_size)
- assert_equal(3, Rss::Channel::Item::Category.indent_size)
- assert_equal(3, Rss::Channel::Item::Guid.indent_size)
- assert_equal(2, Rss::Channel::TextInput.indent_size)
+
+ def test_to_xml
+ rss = RSS::Parser.parse(make_sample_rss20)
+ assert_equal(rss.to_s, rss.to_xml)
+ assert_equal(rss.to_s, rss.to_xml("2.0"))
+ rss09_xml = rss.to_xml("0.91") do |maker|
+ setup_dummy_image(maker)
+ end
+ rss09 = RSS::Parser.parse(rss09_xml)
+ assert_equal("0.91", rss09.rss_version)
+ rss10 = rss.to_xml("1.0") do |maker|
+ maker.channel.about = "http://www.example.com/index.rdf"
+ end
+ rss10 = RSS::Parser.parse(rss10)
+ assert_equal("1.0", rss10.rss_version)
+
+ atom_xml = rss.to_xml("atom1.0") do |maker|
+ maker.channel.id = "http://www.example.com/atom.xml"
+ maker.channel.author = "Alice"
+ maker.channel.updated = Time.now
+ maker.items.each do |item|
+ item.author = "Bob"
+ item.updated = Time.now
+ end
+ end
+ atom = RSS::Parser.parse(atom_xml)
+ assert_equal(["atom", "1.0", "feed"], atom.feed_info)
end
end
end