- fixed a typo in a the chosen view debug message
[catagits/Catalyst-View-Email.git] / t / 05template.t
CommitLineData
82300460 1use strict;
2use warnings;
8b10ee55 3use Test::More;
82300460 4
5use Email::Send::Test;
6use FindBin;
7use lib "$FindBin::Bin/lib";
8
8b10ee55 9eval "use Catalyst::View::TT";
10if ( $@ ) {
11 plan skip_all => 'Catalyst::View::TT required for Template tests';
12 exit;
13}
14plan tests => 10;
15
82300460 16use_ok('Catalyst::Test', 'TestApp');
17
18my $response;
19my $time = time;
20ok( ( $response = request("/template_email?time=$time"))->is_success,
21 'request ok' );
22like( $response->content, qr/Template Email Ok/, 'controller says ok' );
23my @emails = Email::Send::Test->emails;
24
25cmp_ok(@emails, '==', 1, 'got emails');
26isa_ok( $emails[0], 'Email::MIME', 'email is ok' );
27my @parts = $emails[0]->parts;
28cmp_ok(@parts, '==', 2, 'got parts');
29
30is($parts[0]->content_type, 'text/plain; charset="us-ascii"', 'text/plain ok');
fd0033bc 31like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back');
82300460 32is($parts[1]->content_type, 'text/html; charset="us-ascii"', 'text/html ok');
fd0033bc 33like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
82300460 34#like($emails[0]->body, qr/$time/, 'Got our email');
35