2019-09-01 19:49:30 +00:00
defmodule FeedParser.Parser.RSS2Test do
use ExUnit.Case
alias FeedParser.Parser.RSS2
doctest RSS2
test " matches rss2 feed " do
data = File . read! ( " test/fixtures/rss2/feed.xml " )
assert { true , _ } = RSS2 . accepts ( data , " application/rss+xml " )
2021-08-29 23:25:38 +00:00
assert { true , _ } = RSS2 . accepts ( data , " text/rss+xml " )
2019-09-01 19:49:30 +00:00
assert { true , _ } = RSS2 . accepts ( data , " application/xml " )
2021-08-29 23:25:38 +00:00
assert { true , _ } = RSS2 . accepts ( data , " text/xml " )
2019-09-01 19:49:30 +00:00
end
test " parses rss2 feed " do
data = File . read! ( " test/fixtures/rss2/feed.xml " )
{ true , parsed_data } = RSS2 . accepts ( data , " application/rss+xml " )
assert { :ok , % FeedParser.Feed { } = feed } = RSS2 . parse_feed ( parsed_data )
assert feed . title == " Liftoff News "
assert feed . site_url == " http://liftoff.msfc.nasa.gov/ "
2019-09-01 20:11:13 +00:00
assert feed . last_updated == ~U[ 2003-06-10 09:41:01Z ]
2019-09-01 19:49:30 +00:00
assert [ % FeedParser.Item { } = item ] = feed . items
assert item . title == " Star City "
assert item . url == " http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp "
assert item . content ==
" How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's <a href= \" http://howe.iki.rssi.ru/GCTC/gctc_e.htm \" >Star City</a>. "
assert item . date == ~U[ 2003-06-03 09:39:21Z ]
assert item . guid == " http://liftoff.msfc.nasa.gov/2003/06/03.html # item573 "
end
end