[BACK]Return to dudelicious.t CVS log [TXT][DIR] Up to [local] / todotxt / Text-Todo / t

Diff for /todotxt/Text-Todo/t/dudelicious.t between version 1.4 and 1.10

version 1.4, 2010/04/30 02:24:06 version 1.10, 2010/05/05 02:32:12
Line 1 
Line 1 
 #!perl  #!perl
 use Test::More;    # tests => 3;  # $AFresh1: dudelicious.t,v 1.9 2010/05/05 01:24:20 andrew Exp $
   use Test::More tests => 75;
   
 use strict;  use strict;
 use warnings;  use warnings;
Line 8 
Line 9 
 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 );
Line 29 
Line 31 
   
 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 ) );  
     }  
 }  
   
 done_testing();          open my $fh, '<', $f or die $f . ': ' . $!;
           my $content = do { local $/; <$fh> };
           close $fh;
   
           $t->get_ok( $p, {}, undef, "Get [$f] from [$p]" )
               ->status_is(200, 'With 200 status');
   
 sub slurp {          if ( $f =~ /\.json$/xms ) {
     my ($file) = @_;              $t->json_content_is( Mojo::JSON->decode($content),
                   'Check JSON content' );
     local $/;          }
     open my $fh, '<', $file or die $file . ': ' . $!;          else {
     my $content = <$fh>;              $t->content_like( qr/\Q$content\E/xms, 'Check content' );
     close $fh;          }
       }
     return $content;  
 }  }
   
   #done_testing();

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.10

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>