File: | t/test-simpleapp.t |
Coverage: | 100.0% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | #!/usr/bin/env perl -w | ||||||
2 | 1 1 1 | 101 10 9 | use strict; | ||||
3 | 1 1 1 | 10 3 10 | use Cwd; | ||||
4 | 1 1 1 | 101 5 5 | use Moose (); | ||||
5 | |||||||
6 | BEGIN { | ||||||
7 | 1 | 114 | my $cwd = getcwd; | ||||
8 | 1 | 10 | unshift @INC, "$cwd/t/lib"; | ||||
9 | 1 | 9 | unshift @INC, "$cwd/t/SimpleApp/lib"; | ||||
10 | } | ||||||
11 | 1 1 1 | 80 5 17 | use Test::More tests => 1; | ||||
12 | 1 1 1 | 85 5 22 | use Railsish::Dispatcher; | ||||
13 | 1 1 1 | 79 4 13 | use Railsish::Bootstrap; | ||||
14 | 1 1 1 | 82 5 19 | use HTTP::Engine; | ||||
15 | 1 1 1 | 128 4 20 | use HTTP::Request; | ||||
16 | |||||||
17 | 1 | 54 | chdir("t/SimpleApp"); | ||||
18 | 1 1 1 | 82 5 10 | use lib '../../lib'; | ||||
19 | |||||||
20 | 1 | 113 | $ENV{APP_ROOT} = getcwd; | ||||
21 | |||||||
22 | 1 | 12 | Railsish::Bootstrap->load_configs; | ||||
23 | 1 | 36 | Railsish::Bootstrap->load_controllers; | ||||
24 | |||||||
25 | my $engine = HTTP::Engine->new( | ||||||
26 | interface => { | ||||||
27 | module => 'Test', | ||||||
28 | request_handler => sub { | ||||||
29 | 1 | 34 | Railsish::Dispatcher->dispatch(@_) | ||||
30 | } | ||||||
31 | } | ||||||
32 | 1 | 153 | ); | ||||
33 | |||||||
34 | 1 | 78 | my $response = $engine->run( | ||||
35 | HTTP::Request->new(GET => 'http://localhost/welcome/here'), | ||||||
36 | env => \%ENV, | ||||||
37 | connection_info => { | ||||||
38 | request_uri => "/welcome/here" | ||||||
39 | } | ||||||
40 | ); | ||||||
41 | |||||||
42 | 1 | 3 | like $response->content, qr{<p>The answer is 42</p>}; |