hmmm that didn't work
[catagits/Catalyst-View-Email.git] / t / 07mason.t
CommitLineData
8b10ee55 1use strict;
2use warnings;
3use Test::More;
cce24d41 4BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' }
8b10ee55 5use FindBin;
6use lib "$FindBin::Bin/lib";
7
cce24d41 8use Email::Sender::Simple;
9
8b10ee55 10eval "use Catalyst::View::Mason";
11if ( $@ ) {
12 plan skip_all => 'Catalyst::View::Mason required for Mason tests';
13 exit;
14}
8b10ee55 15
16use_ok('Catalyst::Test', 'TestApp');
17
c649c40e 18TestApp->config->{default_view} = 'Mason';
8b10ee55 19my $response;
20my $time = time;
21ok( ( $response = request("/mason_email?time=$time"))->is_success,
22 'request ok' );
23like( $response->content, qr/Mason Email Ok/, 'controller says ok' );
cce24d41 24my @emails = Email::Sender::Simple->default_transport->deliveries;
8b10ee55 25cmp_ok(@emails, '==', 1, 'got emails');
cce24d41 26isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' );
27my @parts = $emails[0]->{'email'}[0]->parts;
8b10ee55 28cmp_ok(@parts, '==', 2, 'got parts');
28151039 29is($parts[0]->content_type, 'text/plain', 'text/plain ok');
8b10ee55 30like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back');
28151039 31is($parts[1]->content_type, 'text/html', 'text/html ok');
8b10ee55 32like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
33#like($emails[0]->body, qr/$time/, 'Got our email');
cce24d41 34done_testing();