Skip to content

Instantly share code, notes, and snippets.

@nikita-d
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikita-d/3add4eb523b6269ac0b8 to your computer and use it in GitHub Desktop.
Save nikita-d/3add4eb523b6269ac0b8 to your computer and use it in GitHub Desktop.
BEGIN {
$ENV{BAIL_ON_FAIL} ||= 1;
}
use Modern::Perl qw|2013|;
use Data::Printer (use_prototypes => 0);
use Test::Most;
use Mojo::DOM;
my $rss = "<channel>
<link>http://host.example</link>
<description>Lorem ipsum dolor sit amet</description>
<encoding>UTF-8</encoding>
<language>ru-ru</language>
<title>RSS Channel Title</title>
</channel>
";
my $dom = Mojo::DOM->new($rss);
$dom->xml(1);
is($dom->xml, 1, 'xml semantics enabled');
is($dom->at("channel > title")->text, 'RSS Channel Title', 'correct title');
is($dom->at("channel > encoding")->text, 'UTF-8', 'correct encoding');
is($dom->at("channel > language")->text, 'ru-ru', 'correct language');
is($dom->at("channel > link")->text, 'http://host.example', 'correct link') ; # - this one fails
say p $dom."";
# "<channel>
# <link />http://host.example
# <description>Lorem ipsum dolor sit amet</description>
# <encoding>UTF-8</encoding>
# <language>ru-ru</language>
# <title>RSS Channel Title</title>
# </channel>
# "
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment