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