#!/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
enNews and commentary from the cross-platform scripting community.
http://www.scripting.com/
Scripting News
http://www.scripting.com/
Scripting Newshttp://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 GMTThu, 08 Jul 1999 16:20:26 GMThttp://my.userland.com/stories/storyReader$11News and commentary from the cross-platform scripting community.
http://www.scripting.com/
Scripting News
http://www.scripting.com/
Scripting Newshttp://www.scripting.com/gifs/tinyScriptingNews.gif4078What is this used for?dave@userland.com (Dave Winer)dave@userland.com (Dave Winer)en-us67891011Sunday(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 stuffsecond item's title
http://link2
aa bb cc
dd ee ffSearch 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('