=================================================================== RCS file: /cvs/todotxt/Text-Todo-REST-API/t/response.t,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- todotxt/Text-Todo-REST-API/t/response.t 2010/01/23 07:04:43 1.1 +++ todotxt/Text-Todo-REST-API/t/response.t 2010/01/26 05:47:30 1.2 @@ -7,13 +7,13 @@ # AUTHOR: Andrew Fresh (AAF), andrew@cpan.org # COMPANY: Red River Communications # CREATED: 01/07/10 19:11 -# REVISION: $AFresh1$ +# REVISION: $AFresh1: response.t,v 1.1 2010/01/23 07:04:43 andrew Exp $ #=============================================================================== use strict; use warnings; -use Test::More tests => 49; +use Test::More tests => 61; my $class; @@ -26,12 +26,12 @@ my %data = ( files => ['todo.txt'], - list => [ - { text => 'uno', md5 => 'XXX md5 of uno XXX' }, - { text => 'dos', md5 => 'XXX md5 of dos XXX' }, - { text => 'tre', md5 => 'XXX md5 of tre XXX' }, + list => [ + { text => 'uno', md5 => 'XXX md5 of uno XXX' }, + { text => 'dos', md5 => 'XXX md5 of dos XXX' }, + { text => 'tre', md5 => 'XXX md5 of tre XXX' }, ], - entry => { text => 'ety', md5 => 'XXX md5 of ety XXX' }, + entry => { text => 'ety', md5 => 'XXX md5 of ety XXX' }, ); my %TESTS = ( @@ -46,12 +46,14 @@ result => '/^Unable to handle \[render_files\] for format \[\]/', }, text => { - result => undef, - data_result => "todo.txt\n" + result => undef, + data_result => "todo.txt\n", + content_type => 'text/plain', }, md5 => { result => '/^Unable to handle \[render_files\] for format \[md5\]/', + content_type => 'text/plain', }, }, @@ -62,11 +64,16 @@ text => { result => undef, data_result => ( join q{}, map "$_->{text}\n", @{ $data{list} } ), + content_type => 'text/plain', }, md5 => { - result => undef, - data_result => ( join q{}, map "MD5 ($_->{text}) = $_->{md5}\n", - @{ $data{list} } ), + result => undef, + data_result => ( + join q{}, + map "MD5 ($_->{text}) = $_->{md5}\n", + @{ $data{list} } + ), + content_type => 'text/plain', }, }, @@ -75,13 +82,17 @@ result => '/^Unable to handle \[render_entry\] for format \[\]/', }, text => { - result => undef, - data_result => ( join q{}, map "$_->{text}\n", $data{entry} ), + result => undef, + data_result => ( join q{}, map "$_->{text}\n", $data{entry} ), + content_type => 'text/plain', }, md5 => { - result => undef, - data_result => ( join q{}, map "MD5 ($_->{text}) = $_->{md5}\n", - $data{entry} ), + result => undef, + data_result => ( + join q{}, map "MD5 ($_->{text}) = $_->{md5}\n", + $data{entry} + ), + content_type => 'text/plain', }, }, ); @@ -121,6 +132,11 @@ my $response = new_ok( $class, [$args] ); + if ( exists $test->{content_type} ) { + is( $response->content_type, $test->{content_type}, + 'Got content_type - ' . $diag ); + } + my $expected = $test->{result}; if ( $args->{data} && exists $test->{data_result} ) { $expected = $test->{data_result}; @@ -129,7 +145,7 @@ my $result; eval { $result = $response->render() }; if ($@) { - if (index $expected, '/') { + if ( index $expected, '/' ) { $expected = '/^$/'; } @@ -138,5 +154,6 @@ else { is( $result, $expected, 'Got expected result - ' . $diag ); } + return 1; }