CatalystX-Routes

 view release on metacpan or  search on metacpan

t/routes.t  view on Meta::CPAN

use strict;
use warnings;

use Test::More 0.88;

use lib 't/lib';
use Catalyst::Test 'MyApp1';
use HTTP::Request::Common qw( GET PUT POST DELETE );

{
    request( GET '/foo', ( Accept => 'application/json' ) );

    is(
        $MyApp1::Controller::C1::REQ{get}, 1,
        'GET request for /foo went to the right sub'
    );

    request( GET '/foo', ( Accept => '*/*' ) );

    is(
        $MyApp1::Controller::C1::REQ{get_html}, 1,
        'GET request for /foo that looks like a browser went to the right sub'
    );

    request( POST '/foo' );

    is(
        $MyApp1::Controller::C1::REQ{post}, 1,
        'POST request for /foo went to the right sub'
    );

    request( PUT '/foo' );

    is(
        $MyApp1::Controller::C1::REQ{put}, 1,
        'PUT request for /foo went to the right sub'
    );

    request( DELETE '/foo' );

    is(
        $MyApp1::Controller::C1::REQ{delete}, 1,
        'DELETE request for /foo went to the right sub'
    );
}

{
    request( GET '/c1/bar', ( Accept => 'application/json' ) );

    is(
        $MyApp1::Controller::C1::REQ{get}, 2,
        'GET request for /c1/bar went to the right sub'
    );

    request( GET '/c1/bar', ( Accept => '*/*', ) );

    is(
        $MyApp1::Controller::C1::REQ{get_html}, 2,
        'GET request for /c1/bar that looks like a browser went to the right sub'
    );

    request( POST '/c1/bar' );

    is(
        $MyApp1::Controller::C1::REQ{post}, 2,
        'POST request for /c1/bar went to the right sub'
    );



( run in 0.451 second using v1.01-cache-2.11-cpan-870870ed90f )