#!/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