require 'test/unit' require 'feed_tools' class CdfTest < Test::Unit::TestCase def setup FeedTools.tidy_enabled = false end def test_feed_title feed = FeedTools::Feed.new feed.feed_data = <<-FEED Example Title FEED assert_equal("Example Title", feed.title) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/cdf/channel_title.xml') assert_equal("Example feed", feed.title) assert_equal(false, feed.bozo?) end def test_feed_description feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/cdf/' + 'channel_abstract_map_description.xml') assert_equal("Example description", feed.description) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/cdf/' + 'channel_abstract_map_tagline.xml') assert_equal("Example description", feed.tagline) assert_equal(false, feed.bozo?) end def test_feed_href feed = FeedTools::Feed.new feed.feed_data = <<-FEED FEED assert_equal("http://www.example.com/", feed.link) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/cdf/channel_href_map_link.xml') assert_equal("http://www.example.org/", feed.link) assert_equal(false, feed.bozo?) end def test_feed_links # TODO end def test_feed_images feed = FeedTools::Feed.new feed.feed_data = <<-FEED FEED assert_equal("http://www.example.com/exampleicon.gif", feed.images[0].url) assert_equal("icon", feed.images[0].style) assert_equal("http://www.example.com/exampleimage.gif", feed.images[1].url) assert_equal("image", feed.images[1].style) assert_equal(false, feed.bozo?) end def test_feed_item_title feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/cdf/item_title.xml') assert_equal("Example item", feed.items.first.title) assert_equal(false, feed.bozo?) end def test_feed_item_description feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/cdf/' + 'item_abstract_map_description.xml') assert_equal("Example description", feed.items.first.description) assert_equal(false, feed.bozo?) feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/cdf/' + 'item_abstract_map_summary.xml') assert_equal("Example description", feed.items.first.summary) assert_equal(false, feed.bozo?) end def test_feed_item_href feed = FeedTools::Feed.open( 'http://feedparser.org/tests/wellformed/cdf/item_href_map_link.xml') assert_equal("http://www.example.org/", feed.items.first.link) assert_equal(false, feed.bozo?) end def test_feed_item_links # TODO end def test_feed_item_images feed = FeedTools::Feed.new feed.feed_data = <<-FEED FEED assert_equal("http://www.example.com/item", feed.items.first.link) assert_equal("http://www.example.com/exampleicon.gif", feed.items.first.images[0].url) assert_equal("icon", feed.items.first.images[0].style) assert_equal("http://www.example.com/exampleimage.gif", feed.items.first.images[1].url) assert_equal("image", feed.items.first.images[1].style) assert_equal(false, feed.bozo?) end end