App-Followme
view release on metacpan or search on metacpan
#!/usr/bin/env perl
use strict;
use Test::More tests => 9;
use IO::File;
use File::Path qw(rmtree);
use File::Spec::Functions qw(catdir catfile rel2abs splitdir);
#----------------------------------------------------------------------
# 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";
require App::Followme::Module;
my $test_dir = catdir(@path, 'test');
rmtree($test_dir, 0, 1) if -e $test_dir;
mkdir $test_dir;
my $subdir = catfile(@path, 'test', 'sub');
mkdir ($subdir) unless -e $subdir;
chdir $test_dir or die $!;
my $template_file = catfile($test_dir, 'template.htm');
#----------------------------------------------------------------------
# Create object
my %configuration = (top_directory => $test_dir,
base_directory => $test_dir,
template_directory => 'sub',
template_file => $template_file
);
my $obj = App::Followme::Module->new(%configuration);
isa_ok($obj, "App::Followme::Module"); # test 1
can_ok($obj, qw(new run)); # test 2
#----------------------------------------------------------------------
# Write test pages
do {
my $template = <<'EOQ';
<html>
<head>
<!-- section meta -->
<title>$title</title>
<meta name="date" content="$date" />
<!-- endsection meta -->
</head>
<body>
<!-- section primary -->
( run in 1.240 second using v1.01-cache-2.11-cpan-39bf76dae61 )