X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Froutes.t;fp=t%2Froutes.t;h=9f63dd26c8a7c56ab93029dc198f14bc6a83d2fa;hb=69d9fc4e5373a24f09d58f289d7b773b186a8479;hp=ef7c160008e141e42d5a6fad8dcd411d3e1baafd;hpb=c4057ce2f2c930b39d3eae35c1ad1bbcffb576dd;p=catagits%2FCatalystX-Routes.git diff --git a/t/routes.t b/t/routes.t index ef7c160..9f63dd2 100644 --- a/t/routes.t +++ b/t/routes.t @@ -4,15 +4,61 @@ use warnings; use Test::More 0.88; use lib 't/lib'; -use MyApp1; +use Catalyst::Test 'MyApp1'; +use HTTP::Request::Common qw( GET PUT POST DELETE ); -my $app = MyApp1->new(); +get('/foo'); -ok( $app, 'instantiated MyApp1' ); +is( + $MyApp1::Controller::C1::REQ{get}, 1, + 'GET request for /foo went to the right sub' +); -my $action = $app->dispatcher()->get_action('/foo'); +request( + GET '/foo', + [ + Accept => '*/*', + ] +); -ok( $action, 'got an action for /foo' ); +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' +); + +get('/normal'); + +is( + $MyApp1::Controller::C1::REQ{normal}, 1, + 'GET request for /norma went to the right sub' +); + +request( POST '/normal' ); + +is( + $MyApp1::Controller::C1::REQ{normal}, 2, + 'POST request for /norma went to the right sub' +); done_testing();