App-jupiter

 view release on metacpan or  search on metacpan

t/atom.t  view on Meta::CPAN

  <updated>2005-07-31T12:29:29Z</updated>
  <id>tag:example.org,2003:3</id>
  <link rel="alternate" type="text/html"
   hreflang="en" href="http://example.org/"/>
  <link rel="self" type="application/atom+xml"
   href="http://example.org/feed.atom"/>
  <rights>Copyright (c) 2003, Mark Pilgrim</rights>
  <generator uri="http://www.example.com/" version="1.0">
    Example Toolkit
  </generator>
  <entry>
    <title>Atom draft-07 snapshot</title>
    <link rel="alternate" type="text/html"
     href="http://example.org/2005/04/02/atom"/>
    <link rel="enclosure" type="audio/mpeg" length="1337"
     href="http://example.org/audio/ph34r_my_podcast.mp3"/>
    <id>tag:example.org,2003:3.2397</id>
    <updated>2005-07-31T12:29:29Z</updated>
    <published>2003-12-13T08:29:29-04:00</published>
    <author>
      <name>Mark Pilgrim</name>
      <uri>http://example.org/</uri>
      <email>f8dy@example.com</email>
    </author>
    <contributor>
      <name>Sam Ruby</name>
    </contributor>
    <contributor>
      <name>Joe Gregorio</name>
    </contributor>
    <content type="xhtml" xml:lang="en"
     xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
	<p><i>[Update: The Atom draft is finished.]</i></p>
      </div>
    </content>
  </entry>
  <entry>
    <title>HTML Example</title>
    <link rel="alternate" type="text/html"
     href="http://example.org/test.html"/>
    <content type="html">&lt;p&gt;&lt;i&gt;Yeah!&lt;/i&gt;&lt;/p&gt;</content>
  </entry>
</feed>
EOT

start_daemon(encode_utf8 $atom);

Jupiter::update_cache("test-$id/rss2sample.opml");

stop_daemon();

Jupiter::make_html("test-$id/rss2sample.html", "test-$id/rss2sample.xml", "test-$id/rss2sample.opml");

my $doc = XML::LibXML->load_html(location => "test-$id/rss2sample.html");
is($doc->findvalue('//h1'), "Planet", "HTML title");
is($doc->findvalue('//div[@class="post"][position()=1]/h3'), "dive into mark — Atom draft-07 snapshot", "Entry title");
is($doc->findvalue('//div[@class="post"][position()=1]/div[@class="content"]'), "[Update: The Atom draft is finished.]", "Entry content");

$doc = XML::LibXML->load_xml(location => "test-$id/rss2sample.xml");
is($doc->findvalue('//item[position()=1]/title'), "Atom draft-07 snapshot", "XHTML Item title");
my @nodes = $doc->findnodes('//item[position()=1]/description');
my $node = shift(@nodes);
like($node->toString, qr(&lt;p&gt;&lt;i&gt;\[Update: The Atom draft is finished\.\]&lt;/i&gt;&lt;/p&gt;),
     "XHTML Item description");

is($doc->findvalue('//item[position()=2]/title'), "HTML Example", "HTML Item title");
@nodes = $doc->findnodes('//item[position()=2]/description');
$node = shift(@nodes);
like($node->toString, qr(&lt;p&gt;&lt;i&gt;Yeah!&lt;/i&gt;&lt;/p&gt;),
     "HTML Item description");

done_testing();



( run in 0.963 second using v1.01-cache-2.11-cpan-39bf76dae61 )