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)
feed = FeedTools::Feed.open(
'http://feedparser.org/tests/wellformed/cdf/channel_title.xml')
assert_equal("Example feed", feed.title)
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)
feed = FeedTools::Feed.open(
'http://feedparser.org/tests/wellformed/cdf/' +
'channel_abstract_map_tagline.xml')
assert_equal("Example description", feed.tagline)
end
def test_feed_href
feed = FeedTools::Feed.new
feed.feed_data = <<-FEED
FEED
assert_equal("http://www.example.com/", feed.link)
feed = FeedTools::Feed.open(
'http://feedparser.org/tests/wellformed/cdf/channel_href_map_link.xml')
assert_equal("http://www.example.org/", feed.link)
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)
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)
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)
feed = FeedTools::Feed.open(
'http://feedparser.org/tests/wellformed/cdf/' +
'item_abstract_map_summary.xml')
assert_equal("Example description", feed.items.first.summary)
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)
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)
end
end