X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F05template.t;h=ab5abe4ea4822a2662ebf3aa3bd02aa041ae3ada;hb=502b560653fd758241e2b597ac0849745704365c;hp=b8c6936f888df290b2bbbf395839d1cf34db134a;hpb=8b10ee5587f3331cc2232efad852a2886f6ed0ca;p=catagits%2FCatalyst-View-Email.git diff --git a/t/05template.t b/t/05template.t index b8c6936..ab5abe4 100644 --- a/t/05template.t +++ b/t/05template.t @@ -1,8 +1,10 @@ use strict; use warnings; + +BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' } use Test::More; -use Email::Send::Test; +use Email::Sender::Simple; use FindBin; use lib "$FindBin::Bin/lib"; @@ -11,7 +13,6 @@ if ( $@ ) { plan skip_all => 'Catalyst::View::TT required for Template tests'; exit; } -plan tests => 10; use_ok('Catalyst::Test', 'TestApp'); @@ -19,17 +20,20 @@ my $response; my $time = time; ok( ( $response = request("/template_email?time=$time"))->is_success, 'request ok' ); +my @emails = Email::Sender::Simple->default_transport->deliveries; like( $response->content, qr/Template Email Ok/, 'controller says ok' ); -my @emails = Email::Send::Test->emails; - cmp_ok(@emails, '==', 1, 'got emails'); -isa_ok( $emails[0], 'Email::MIME', 'email is ok' ); -my @parts = $emails[0]->parts; +isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' ); + +like($emails[0]->{'email'}[0]->header("Content-type"), qr#^multipart/alternative#, 'Multipart email'); + +my @parts = $emails[0]->{'email'}[0]->parts; cmp_ok(@parts, '==', 2, 'got parts'); -is($parts[0]->content_type, 'text/plain; charset="us-ascii"', 'text/plain ok'); +is($parts[0]->content_type, 'text/plain', 'text/plain part ok'); like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back'); -is($parts[1]->content_type, 'text/html; charset="us-ascii"', 'text/html ok'); + +is($parts[1]->content_type, 'text/html', 'text/html ok'); like($parts[1]->body, qr{test-email\@example.com on $time}, 'got content back'); #like($emails[0]->body, qr/$time/, 'Got our email'); - +done_testing();