Static::Simple: Support a less confusing way to enable logging
[catagits/Catalyst-Plugin-Static-Simple.git] / t / 05dirs.t
CommitLineData
e37ad815 1#!perl\r
2\r
3use strict;\r
4use warnings;\r
5\r
6use FindBin;\r
7use lib "$FindBin::Bin/lib";\r
8\r
c8ee8fd2 9use Test::More tests => 10;\r
e37ad815 10use Catalyst::Test 'TestApp';\r
11\r
12# test defined static dirs\r
13TestApp->config->{static}->{dirs} = [\r
14 'always-static',\r
15 qr/^images/,\r
16 'qr/^css/',\r
17];\r
18\r
19# a file with no extension will return text/plain\r
20ok( my $res = request('http://localhost/always-static/test'), 'request ok' );\r
21is( $res->content_type, 'text/plain', 'text/plain ok' );\r
22\r
c8ee8fd2 23# a file with an extension in ignore_extensions still gets served\r
24ok( $res = request('http://localhost/always-static/test.html'), 'request ok' );\r
25is( $res->code, 200, 'html file in dirs get served' );\r
26\r
e37ad815 27# a missing file in a defined static dir will return 404\r
28ok( $res = request('http://localhost/always-static/404.txt'), 'request ok' );\r
29is( $res->code, 404, '404 ok' );\r
30\r
31# qr regex test\r
32ok( $res = request('http://localhost/images/catalyst.png'), 'request ok' );\r
33is( $res->content_type, 'image/png', 'qr regex path ok' );\r
34\r
35# eval regex test\r
36ok( $res = request('http://localhost/css/static.css'), 'request ok' );\r
37like( $res->content, qr/background/, 'eval regex path ok' );\r