removed some debug stuff
[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}
ab4326b4 14plan tests => 11;
8b10ee55 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' );
ab4326b4 27
28like($emails[0]->content_type, qr#^multipart/alternative#, 'Multipart email');
29
82300460 30my @parts = $emails[0]->parts;
31cmp_ok(@parts, '==', 2, 'got parts');
32
28151039 33is($parts[0]->content_type, 'text/plain', 'text/plain part ok');
fd0033bc 34like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back');
43090696 35
28151039 36is($parts[1]->content_type, 'text/html', 'text/html ok');
fd0033bc 37like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
82300460 38#like($emails[0]->body, qr/$time/, 'Got our email');
39