version 1.4, 2010/04/30 02:24:06 |
version 1.6, 2010/04/30 02:43:14 |
|
|
#!perl |
#!perl |
|
# $AFresh1$ |
use Test::More; # tests => 3; |
use Test::More; # tests => 3; |
|
|
use strict; |
use strict; |
|
|
|
|
my $t = Test::Mojo->new; |
my $t = Test::Mojo->new; |
|
|
|
my @exts = ( q{}, '.html', '.txt', '.json' ); |
|
|
foreach my $p ( |
foreach my $p ( |
'/', |
'/', |
'/l/todo1', |
( map { '/l/todo1' . $_ } @exts ), |
'/l/todo1.html', |
( map { '/l/todo1/e/1' . $_ } @exts ), |
'/l/todo1.txt', |
( map { '/l/todo1/e/4' . $_ } @exts ), |
'/l/todo1.json', |
( map { '/l/todo1/t' . $_ } @exts ), |
'/l/todo1/e/1', |
( map { '/l/todo1/t/project' . $_ } @exts ), |
'/l/todo1/e/1.html', |
( map { '/l/todo1/t/context' . $_ } @exts ), |
'/l/todo1/e/1.json', |
) |
'/l/todo1/t', |
{ |
'/l/todo1/t.txt', |
my ( $volume, $directories, $file ) = File::Spec->splitpath($p); |
'/l/todo1/t.json', |
|
) { |
|
my ($volume, $directories, $file) = File::Spec->splitpath($p); |
|
$file ||= 'index.html'; |
$file ||= 'index.html'; |
|
$file .= '.html' if $file !~ /\.[^.]+$/xms; |
|
|
if ($file !~ /\.[^.]+$/xms) { |
|
$file .= '.html'; |
|
} |
|
|
|
|
|
my $f = File::Spec->catfile( 't', 'dudelicious', $volume, $directories, |
my $f = File::Spec->catfile( 't', 'dudelicious', $volume, $directories, |
$file); |
$file ); |
|
|
SKIP: { |
SKIP: { |
skip "$f does not exist", 3 if ! -e $f; |
skip "$f does not exist", 3 if !-e $f; |
diag( "Getting [$f] from [$p]" ); |
|
$t->get_ok($p)->status_is(200)->content_is( slurp( $f ) ); |
diag("Getting [$f] from [$p]"); |
|
open my $fh, '<', $f or die $f . ': ' . $!; |
|
$t->get_ok($p)->status_is(200)->content_is( |
|
do { local $/; <$fh> } |
|
); |
|
close $fh; |
} |
} |
} |
} |
|
|
done_testing(); |
done_testing(); |
|
|
|
|
sub slurp { |
|
my ($file) = @_; |
|
|
|
local $/; |
|
open my $fh, '<', $file or die $file . ': ' . $!; |
|
my $content = <$fh>; |
|
close $fh; |
|
|
|
return $content; |
|
} |
|