Fix spelling, grammar and structural errors in POD
[catagits/Catalyst-Runtime.git] / t / head_middleware.t
1 use warnings;
2 use strict;
3 use Test::More;
4 use HTTP::Request::Common;
5 use Plack::Test;
6
7 # Test to make sure we the order of some middleware is correct.  Basically
8 # we want to make sure that if the request is a HEAD we properly remove the
9 # body BUT not so quickly that we fail to calculate the length.  This test
10 # exists mainly to prevent regressions.
11
12 {
13   package MyApp::Controller::Root;
14   $INC{'MyApp/Controller/Root.pm'} = __FILE__;
15
16   use base 'Catalyst::Controller';
17
18   sub test :Local {
19     my ($self, $c) = @_;
20     $c->response->body("This is the body");
21   }
22
23   package MyApp;
24   use Catalyst;
25
26   MyApp->setup;
27 }
28
29
30 Test::More::ok(MyApp->setup);
31
32 ok my $psgi = MyApp->psgi_app, 'build psgi app';
33
34 test_psgi $psgi, sub {
35     my $cb = shift;
36     my $res = $cb->(GET "/root/test");
37     is $res->code, 200, 'OK';
38     is $res->content, 'This is the body', 'correct body';
39     is $res->content_length, 16, 'correct length';
40 };
41
42 test_psgi $psgi, sub {
43     my $cb = shift;
44     my $res = $cb->(HEAD "/root/test");
45     is $res->code, 200, 'OK';
46     is $res->content, '', 'correct body';
47     is $res->content_length, 16, 'correct length';    
48 };
49
50 done_testing;