| version 1.8, 2010/01/18 13:47:53 |
version 1.9, 2010/01/19 03:18:34 |
|
|
| # AUTHOR: Andrew Fresh (AAF), andrew@cpan.org |
# AUTHOR: Andrew Fresh (AAF), andrew@cpan.org |
| # COMPANY: Red River Communications |
# COMPANY: Red River Communications |
| # CREATED: 01/07/10 19:11 |
# CREATED: 01/07/10 19:11 |
| # REVISION: $AFresh1: text.t,v 1.7 2010/01/18 03:51:40 andrew Exp $ |
# REVISION: $AFresh1: text.t,v 1.8 2010/01/18 13:47:53 andrew Exp $ |
| #=============================================================================== |
#=============================================================================== |
| |
|
| use strict; |
use strict; |
| use warnings; |
use warnings; |
| |
|
| use Test::More tests => 45; |
use Test::More tests => 43; |
| |
|
| my $class; |
my $class; |
| my $subclass; |
|
| my $ext; |
my $ext; |
| |
|
| BEGIN { |
BEGIN { |
|
|
| |
|
| $class = 'Text::Todo::REST::API'; |
$class = 'Text::Todo::REST::API'; |
| use_ok( $class, "use $class" ); |
use_ok( $class, "use $class" ); |
| |
|
| $subclass = $class . '::Representations::text'; |
|
| } |
} |
| |
|
| diag("Testing entry $subclass $Text::Todo::REST::API::VERSION"); |
diag("Testing entry $class $Text::Todo::REST::API::VERSION"); |
| |
|
| my $api = new_ok( $class, |
my $api = new_ok( $class, |
| [ { todo_dir => 't/lists', path_info => '/.' . $ext } ] ); |
[ { todo_dir => 't/lists', path_info => '/.' . $ext } ] ); |
| isa_ok( $api, $subclass ); |
|
| |
|
| my $files_should_be = ['todo.txt']; |
my $files_should_be = ['todo.txt']; |
| my @files; |
my @files; |
|
|
| |
|
| $api = new_ok( $class, |
$api = new_ok( $class, |
| [ { todo_dir => 't/lists', path_info => '/todo.' . $ext } ] ); |
[ { todo_dir => 't/lists', path_info => '/todo.' . $ext } ] ); |
| isa_ok( $api, $subclass ); |
|
| |
|
| my $list_should_be = [ |
my $list_should_be = [ |
| { 'text' => '(A) entry 1 @one +uno', |
{ 'text' => '(A) entry 1 @one +uno', |
|
|
| map { $_->{text} . "\n" } @{$list_should_be}; |
map { $_->{text} . "\n" } @{$list_should_be}; |
| |
|
| $result = undef; |
$result = undef; |
| ok( !eval { $result = $api->Load() }, 'Load method' ); |
ok( !eval { $result = $api->_handle_representation('load') }, 'Load method' ); |
| like( $@, '/^Unable to Load \[list\]/', 'Failed Load as expected' ); |
like( $@, '/^Unable to load \[list\]/', 'Failed Load as expected' ); |
| |
|
| $result = undef; |
$result = undef; |
| ok( !( $result = $api->Dump() ), 'Dump method' ); |
ok( !( $result = $api->Dump() ), 'Dump method' ); |