From 16ec9aba7e94e628f22bcaeb3ecdd7916f3a3df5 Mon Sep 17 00:00:00 2001 From: lnu Date: Thu, 31 Mar 2005 22:08:32 +0000 Subject: first import git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@5 f70e237a-67f3-0310-a06c-d2b8a7116972 --- test/tc_channel_parse.rb | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100755 test/tc_channel_parse.rb (limited to 'test/tc_channel_parse.rb') diff --git a/test/tc_channel_parse.rb b/test/tc_channel_parse.rb new file mode 100755 index 0000000..d7b34e7 --- /dev/null +++ b/test/tc_channel_parse.rb @@ -0,0 +1,96 @@ +#!/usr/bin/ruby -w + +$:.unshift File.join(File.dirname(__FILE__), '..', 'lib') + +require 'test/unit' +require 'feed2imap/channel' + +class ChannelParserTest < Test::Unit::TestCase + # From http://my.netscape.com/publish/formats/rss-spec-0.91.html + def test_parse_rss091_1 + ch = Channel::new <<-EOF + + + + + en + News and commentary from the cross-platform scripting community. + http://www.scripting.com/ + Scripting News + + http://www.scripting.com/ + Scripting News + http://www.scripting.com/gifs/tinyScriptingNews.gif + + + + EOF + assert_equal('Scripting News', ch.title) + assert_equal('http://www.scripting.com/', ch.link) + assert_equal('News and commentary from the cross-platform scripting community.', ch.description) + assert_equal([], ch.items) + end + + def test_parse_rss091_complete + ch = Channel::new <<-EOF + + + + +Copyright 1997-1999 UserLand Software, Inc. +Thu, 08 Jul 1999 07:00:00 GMT +Thu, 08 Jul 1999 16:20:26 GMT +http://my.userland.com/stories/storyReader$11 +News and commentary from the cross-platform scripting community. +http://www.scripting.com/ +Scripting News + + http://www.scripting.com/ + Scripting News + http://www.scripting.com/gifs/tinyScriptingNews.gif + 40 + 78 + What is this used for? + +dave@userland.com (Dave Winer) +dave@userland.com (Dave Winer) +en-us + + 67891011 + + + Sunday + +(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0)) + + stuff + http://bar + This is an article about some stuff + + + second item's title + http://link2 + aa bb cc + dd ee ff + + + Search Now! + Enter your search <terms> + find + http://my.site.com/search.cgi + + + + EOF + assert_equal('Scripting News', ch.title) + assert_equal('http://www.scripting.com/', ch.link) + assert_equal('News and commentary from the cross-platform scripting community.', ch.description) + assert_equal(2, ch.items.length) + assert_equal('http://bar', ch.items[0].link) + assert_equal('

This is an article about some stuff

', ch.items[0].content) + assert_equal('stuff', ch.items[0].title) + assert_equal('http://link2', ch.items[1].link) + assert_equal("

aa bb cc\n dd ee ff

", ch.items[1].content) + assert_equal('second item\'s title', ch.items[1].title) + end +end -- cgit v1.2.3-70-g09d2