Released Static::Simple 0.08 - Added tests for everything except Apache support
[catagits/Catalyst-Plugin-Static-Simple.git] / t / 05dirs.t
diff --git a/t/05dirs.t b/t/05dirs.t
new file mode 100644 (file)
index 0000000..fa5db8a
--- /dev/null
@@ -0,0 +1,33 @@
+#!perl\r
+\r
+use strict;\r
+use warnings;\r
+\r
+use FindBin;\r
+use lib "$FindBin::Bin/lib";\r
+\r
+use Test::More tests => 8;\r
+use Catalyst::Test 'TestApp';\r
+\r
+# test defined static dirs\r
+TestApp->config->{static}->{dirs} = [\r
+    'always-static',\r
+    qr/^images/,\r
+    'qr/^css/',\r
+];\r
+\r
+# a file with no extension will return text/plain\r
+ok( my $res = request('http://localhost/always-static/test'), 'request ok' );\r
+is( $res->content_type, 'text/plain', 'text/plain ok' );\r
+\r
+# a missing file in a defined static dir will return 404\r
+ok( $res = request('http://localhost/always-static/404.txt'), 'request ok' );\r
+is( $res->code, 404, '404 ok' );\r
+\r
+# qr regex test\r
+ok( $res = request('http://localhost/images/catalyst.png'), 'request ok' );\r
+is( $res->content_type, 'image/png', 'qr regex path ok' );\r
+\r
+# eval regex test\r
+ok( $res = request('http://localhost/css/static.css'), 'request ok' );\r
+like( $res->content, qr/background/, 'eval regex path ok' );\r