| version 1.3, 2010/04/29 05:50:33 |
version 1.7, 2010/04/30 07:18:33 |
|
|
| #!perl |
#!perl |
| |
# $AFresh1: dudelicious.t,v 1.6 2010/04/30 01:43:14 andrew Exp $ |
| use Test::More; # tests => 3; |
use Test::More; # tests => 3; |
| |
|
| use strict; |
use strict; |
|
|
| use File::Copy qw/ cp /; |
use File::Copy qw/ cp /; |
| use File::Spec; |
use File::Spec; |
| |
|
| |
my $have_test_json = 1; |
| |
|
| BEGIN { |
BEGIN { |
| eval "use Test::Mojo"; |
eval "use Test::Mojo"; |
| plan skip_all => "Test::Mojo required for testing dudelicious" if $@; |
plan skip_all => "Test::Mojo required for testing dudelicious" if $@; |
| |
|
| } |
} |
| |
|
| my $todo_dir = tempdir( 'todo-XXXXXXXXX', CLEANUP => 1, TMPDIR => 1 ); |
my $todo_dir = tempdir( 'todo-XXXXXXXXX', CLEANUP => 1, TMPDIR => 1 ); |
|
|
| |
|
| my $t = Test::Mojo->new; |
my $t = Test::Mojo->new; |
| |
|
| # Index page |
my @exts = ( q{}, '.html', '.txt', '.json' ); |
| $t->get_ok('/')->status_is(200)->content_like(qr/todo1\.txt/xms); |
|
| |
|
| $t->get_ok('/l/todo1')->status_is(200)->content_is( |
foreach my $p ( |
| q{<!doctype html><html> |
'/', |
| <head><title>Funky!</title></head> |
( map { '/l/todo1' . $_ } @exts ), |
| <body><h1>todo1</h1> |
( map { '/l/todo1/e/1' . $_ } @exts ), |
| <ol> |
( map { '/l/todo1/e/4' . $_ } @exts ), |
| <li> |
( map { '/l/todo1/t' . $_ } @exts ), |
| (B) +GarageSale @phone schedule Goodwill pickup |
( map { '/l/todo1/t/project' . $_ } @exts ), |
| </li> |
( map { '/l/todo1/t/context' . $_ } @exts ), |
| <li> |
) |
| +GarageSale @home post signs around the neighborhood DUE:2006-08-01 |
{ |
| </li> |
my ( $volume, $directories, $file ) = File::Spec->splitpath($p); |
| <li> |
|
| X eat meatballs @home |
|
| </li> |
|
| <li> |
|
| (A) @phone thank Mom for the meatballs WAIT |
|
| </li> |
|
| <li> |
|
| |
|
| </li> |
$file ||= 'index.html'; |
| <li> |
$file .= '.html' if $file !~ /\.[^.]+$/xms; |
| @shopping Eskimo pies |
|
| </li> |
|
| <li> |
|
| email andrew@cpan.org for help +report_bug @wherever |
|
| </li> |
|
| <li> |
|
| x 2009-01-01 completed with a date |
|
| </li> |
|
| </ol> |
|
| </body> |
|
| </html> |
|
| } |
|
| ); |
|
| |
|
| $t->get_ok('/l/todo1.txt')->status_is(200)->content_is( |
my $f = File::Spec->catfile( 't', 'dudelicious', $volume, $directories, |
| q{(B) +GarageSale @phone schedule Goodwill pickup |
$file ); |
| +GarageSale @home post signs around the neighborhood DUE:2006-08-01 |
|
| X eat meatballs @home |
|
| (A) @phone thank Mom for the meatballs WAIT |
|
| |
|
| @shopping Eskimo pies |
SKIP: { |
| email andrew@cpan.org for help +report_bug @wherever |
skip "$f does not exist", 3 if !-e $f; |
| x 2009-01-01 completed with a date |
diag("Get [$f] from [$p]"); |
| } |
|
| ); |
|
| |
|
| $t->get_ok('/l/todo1/e/1')->status_is(200)->content_is( |
open my $fh, '<', $f or die $f . ': ' . $!; |
| q{<!doctype html><html> |
my $content = do { local $/; <$fh> }; |
| <head><title>Funky!</title></head> |
close $fh; |
| <body>(B) +GarageSale @phone schedule Goodwill pickup |
|
| </body> |
|
| </html> |
|
| } |
|
| ); |
|
| |
|
| $t->get_ok('/l/todo1/e/1.txt')->status_is(200)->content_is( |
if ( $f =~ /\.json$/xms ) { |
| q{(B) +GarageSale @phone schedule Goodwill pickup |
$t->get_ok($p)->status_is(200) |
| |
->json_content_is( Mojo::JSON->decode($content), |
| |
'Check JSON content' ); |
| |
} |
| |
else { |
| |
$t->get_ok($p)->status_is(200) |
| |
->content_is( $content, 'Check content' ); |
| |
} |
| |
} |
| } |
} |
| ); |
|
| |
|
| done_testing(); |
done_testing(); |