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