File Coverage

File:t/response-redirect.t
Coverage:96.5%

linestmtbrancondsubpodtimecode
1#!/usr/bin/env perl
2
3
1
1
1
103
10
11
use strict;
4
1
1
1
10
3
11
use warnings;
5
1
1
1
113
6
5
use Moose ();
6
1
1
1
92
5
16
use Test::More tests => 4;
7
8package FooController;
9
1
1
1
85
5
13
use Railsish::Controller;
10
11sub bar {
12
0
0
    response->body("bar");
13}
14
15sub baz {
16
1
10
    redirect_to("/foo/bar");
17}
18
19sub bax {
20
1
10
    redirect_to(action => "bar")
21}
22
23package main;
24
1
1
1
77
7
16
use Railsish::Router;
25
1
1
1
87
6
21
use Railsish::Dispatcher;
26
1
1
1
80
5
16
use HTTP::Engine;
27
1
1
1
86
4
19
use HTTP::Request;
28
29Railsish::Router->draw(
30    sub {
31
1
6
        my ($map) = @_;
32
1
8
        $map->connect("/:controller/:action");
33    }
34
1
27
);
35
36
37my $engine = HTTP::Engine->new(
38    interface => {
39        module => "Test",
40        request_handler => sub {
41
2
61
            Railsish::Dispatcher->dispatch(@_);
42        }
43    }
44
1
30
);
45
46{
47
1
1
68
12
    my $response = $engine->run(HTTP::Request->new(GET => "http://localhost/foo/baz"));
48
1
3
    ok($response->is_redirect);
49
1
28
    is($response->header("Location"), "/foo/bar");
50}
51
52{
53
1
1
18
15
    my $response = $engine->run(HTTP::Request->new(GET => "http://localhost/foo/bax"));
54
1
3
    ok($response->is_redirect);
55
1
15
    is($response->header("Location"), "/foo/bar");
56}
57