Change configuration key to 'Plugin::Static::Simple' by default.
[catagits/Catalyst-Plugin-Static-Simple.git] / t / 20debug.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use FindBin;
7 use lib "$FindBin::Bin/lib";
8
9 use Test::More tests => 5;
10 use Catalyst::Test 'TestApp';
11
12 # test defined static dirs
13 TestApp->config->{'Plugin::Static::Simple'}->{dirs} = [
14     'always-static',
15 ];
16
17 TestApp->config->{'Plugin::Static::Simple'}->{debug} = 1;
18
19 use Catalyst::Log;
20
21 local *Catalyst::Log::_send_to_log;
22 local our @MESSAGES;
23 {
24     no warnings 'redefine';
25     *Catalyst::Log::_send_to_log = sub {
26         my $self = shift;
27         push @MESSAGES, @_;
28     };
29 }
30
31
32 # a missing file in a defined static dir will return 404 and text/html
33 ok( my $res = request('http://localhost/always-static/404.txt'), 'request ok' );
34 is( $res->code, 404, '404 ok' );
35 is( $res->content_type, 'text/html', '404 is text/html' );
36 ok(defined $MESSAGES[0], 'debug message set');
37 like( $MESSAGES[0], qr/404/, 'debug message contains 404');
38