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