App-Followme
view release on metacpan or search on metacpan
t/CreateRss.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use IO::File;
use File::Path qw(rmtree);
use File::Spec::Functions qw(catdir catfile rel2abs splitdir);
use Test::More tests => 20;
#----------------------------------------------------------------------
# Change the modification date of a file
sub age {
my ($filename, $sec) = @_;
return unless -e $filename;
return if $sec <= 0;
my @stats = stat($filename);
my $date = $stats[9];
$date -= $sec;
utime($date, $date, $filename);
return;
}
#----------------------------------------------------------------------
# Load package
my @path = splitdir(rel2abs($0));
pop(@path);
pop(@path);
my $lib = catdir(@path, 'lib');
unshift(@INC, $lib);
eval "use App::Followme::FIO";
eval "use App::Followme::NestedText";
require App::Followme::CreateRss;
my $test_dir = catdir(@path, 'test');
rmtree($test_dir, 0, 1) if -e $test_dir;
mkdir($test_dir) unless -e $test_dir;
chdir $test_dir or die $!;
#----------------------------------------------------------------------
# Create object
my $site_url = 'http://www.example.com';
my $remote_url = 'http://cloudhost.com';
my %configuration = (
top_directory => $test_dir,
base_directory => $test_dir,
author => 'Bernie Simon',
site_url => $site_url,
remote_url => $remote_url,
list_length => 3,
web_extension => 'html',
);
my $idx = App::Followme::CreateRss->new(%configuration);
isa_ok($idx, "App::Followme::CreateRss"); # test 1
can_ok($idx, qw(new run)); # test 2
#----------------------------------------------------------------------
# Create rss file
do {
my $page = <<'EOQ';
<html>
<head>
<meta name="robots" content="archive">
<!-- section meta -->
<title>Post %%</title>
<meta name="description" content="This is a page about %%" />
( run in 0.526 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )