File Coverage

File:t/mini-app.t
Coverage:100.0%

linestmtbrancondsubpodtimecode
1#!/usr/bin/env perl -w
2
1
1
1
101
9
11
use strict;
3
1
1
1
10
3
11
use warnings;
4
1
1
1
130
5
5
use Moose ();
5
1
1
1
94
5
20
use Test::More tests => 1;;
6
7package FooController;
8
1
1
1
87
4
16
use Railsish::Controller;
9
1
1
1
11
3
21
use Test::More;
10
11sub bar {
12
1
9
    response->body( params("id") );
13}
14
15package main;
16
1
1
1
78
8
16
use Railsish::Router;
17
18Railsish::Router->draw(
19    sub {
20
1
6
        my ($map) = @_;
21
1
9
        $map->connect("/:controller/:action/:id");
22
1
25
        $map->connect("/:controller/:action");
23
1
24
        $map->connect("/:controller", action => 'index');
24
25
1
25
        $map->connect("", controller => "foo");
26    }
27
1
26
);
28
29
1
1
1
154
6
19
use Railsish::Dispatcher;
30
1
1
1
79
5
18
use HTTP::Engine;
31
32
1
1
1
90
4
20
use HTTP::Request;
33
34my $response = HTTP::Engine->new(
35    interface => {
36        module => "Test",
37        request_handler => sub {
38
1
33
            Railsish::Dispatcher->dispatch(@_);
39        }
40    }
41
1
35
)->run(
42    HTTP::Request->new(
43        GET => "http://localhost/foo/bar/baz"
44    )
45);
46
47# The returned $response is a HTTP::Response object
48
49
1
2
is($response->content, "baz");