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