[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.2 and 1.7

version 1.2, 2010/04/28 01:33:05 version 1.7, 2010/04/30 07:18:33
Line 1 
Line 1 
 use Test::More tests => 3;  #!perl
   # $AFresh1: dudelicious.t,v 1.6 2010/04/30 01:43:14 andrew Exp $
   use Test::More;    # tests => 3;
   
   use strict;
   use warnings;
   
   use File::Temp qw/ tempdir /;
   use File::Copy qw/ cp /;
   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 $@;
   }
   
         use lib 'bin';  my $todo_dir = tempdir( 'todo-XXXXXXXXX', CLEANUP => 1, TMPDIR => 1 );
         require 'dudelicious.pl';  $ENV{DUDELICIOUS_HOME} = $todo_dir;
         Dudelicious->import;  
   foreach my $file qw( todo1.txt todo.list.txt dudelicious.conf ) {
       cp( File::Spec->catfile( 't',       $file ),
           File::Spec->catfile( $todo_dir, $file ),
       ) || die "Couldn't cp [$todo_dir]/[$file]: $!";
 }  }
   
 my $app = Dudelicious::app;  require File::Spec->catfile( 'bin', 'dudelicious.pl' );
 $app->log->level('error');  Dudelicious->import;
   Dudelicious->app->log->level('error');
   
 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/Funky/);  
   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);
   
       $file ||= 'index.html';
       $file .= '.html' if $file !~ /\.[^.]+$/xms;
   
       my $f = File::Spec->catfile( 't', 'dudelicious', $volume, $directories,
           $file );
   
   SKIP: {
           skip "$f does not exist", 3 if !-e $f;
           diag("Get [$f] from [$p]");
   
           open my $fh, '<', $f or die $f . ': ' . $!;
           my $content = do { local $/; <$fh> };
           close $fh;
   
           if ( $f =~ /\.json$/xms ) {
               $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();

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.7

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