require 'test/unit' require 'feed_tools' # testing is done with the cache turned off FeedTools.feed_cache = nil class RssTest < Test::Unit::TestCase def setup end def test_feed_well_formed feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/aaa_wellformed.xml') assert_equal(false, feed.bozo?) end def test_feed_title feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/channel_title.xml') assert_equal("Example feed", feed.title) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/channel_title_apos.xml') assert_equal("Mark's title", feed.title) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/channel_title_gt.xml') assert_equal("2 > 1", feed.title) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/channel_title_lt.xml') assert_equal("1 < 2", feed.title) assert_equal(false, feed.bozo?) end def test_feed_description feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/channel_description.xml') assert_equal("Example description", feed.description) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/' + 'channel_description_escaped_markup.xml') assert_equal("

Example description

", feed.description) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/' + 'channel_description_map_tagline.xml') assert_equal("Example description", feed.tagline) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/' + 'channel_description_naked_markup.xml') assert_equal("

Example description

", feed.description) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/' + 'channel_description_shorttag.xml') assert_equal(nil, feed.description) assert_equal('http://example.com/', feed.link) assert_equal(false, feed.bozo?) end def test_feed_generator feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/channel_generator.xml') assert_equal("Example generator", feed.generator) assert_equal(false, feed.bozo?) end def test_feed_docs feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/channel_docs.xml') assert_equal("http://www.example.com/", feed.docs) assert_equal(false, feed.bozo?) end def test_feed_ttl feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/channel_ttl.xml') assert_equal(1.hour, feed.ttl) assert_equal(false, feed.bozo?) end def test_item_content feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/item_content_encoded.xml') assert_equal('

Example content

', feed.entries.first.content) assert_equal(false, feed.bozo?) end def test_item_description feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/item_description.xml') assert_equal('Example description', feed.entries.first.description) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/' + 'item_description_escaped_markup.xml') assert_equal('

Example description

', feed.entries.first.description) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/' + 'item_description_map_summary.xml') assert_equal('Example description', feed.entries.first.description) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/' + 'item_description_naked_markup.xml') assert_equal('

Example description

', feed.entries.first.description) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/' + 'item_description_not_a_doctype.xml') assert_equal('<!\' ', feed.entries.first.description) assert_equal(false, feed.bozo?) end def test_item_guid feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/item_guid.xml') assert_equal('http://guid.example.com/', feed.entries.first.guid) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/' + 'item_guid_conflict_link.xml') assert_equal('http://guid.example.com/', feed.entries.first.guid) assert_equal('http://link.example.com/', feed.entries.first.link) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/rss/item_guid_guidislink.xml') assert_equal('http://guid.example.com/', feed.entries.first.guid) assert_equal('http://guid.example.com/', feed.entries.first.link) assert_equal(false, feed.bozo?) end end