File: 015_feed_exceptions.t

package info (click to toggle)
libxml-rss-feed-perl 2.212-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 312 kB
  • sloc: perl: 2,581; makefile: 2
file content (31 lines) | stat: -rwxr-xr-x 824 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 6;
use Time::HiRes;

BEGIN { use_ok('XML::RSS::Feed') }

my $feed = XML::RSS::Feed->new(
    url            => "http://www.jbisbee.com/rdf/",
    name           => 'jbisbee',
    headline_as_id => 1,
);

$SIG{__WARN__} = build_warn("Failed to parse RSS XML");
$feed->parse("malformed XML string");
ok( $feed->num_headlines == 0, "force parse to fail" );

$feed->process( [] );
ok( $feed->num_headlines == 0, "call process without any items" );

$SIG{__WARN__} = build_warn(
    "Either item, url/headline. or url/description are required");
$feed->process( [ { bad => 1 } ] );

ok( $feed->num_headlines == 0, "call process with one bad item" );

sub build_warn {
    my @args = @_;
    return sub { my ($warn) = @_; like( $warn, qr/$_/i, $_ ) for @args };
}