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