X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Fdata_handler.t;h=d51143dc7f19a32c19e9631ee7b5c1b21ede25d7;hp=26ce2f9e1a242f6a83cc1fe49d3d3bec83fc17d2;hb=fe51b31bbe095f5c33e95082a5c31e817ffe6d6a;hpb=e2aa4a2182ee4503a91c66b05ac9c3371e61ed5c diff --git a/t/data_handler.t b/t/data_handler.t index 26ce2f9..d51143d 100644 --- a/t/data_handler.t +++ b/t/data_handler.t @@ -12,13 +12,31 @@ use lib "$FindBin::Bin/lib"; use Catalyst::Test 'TestDataHandlers'; ok my($res, $c) = ctx_request('/'); -ok my $message = 'helloworld'; -ok my $post = encode_json +{message=>$message}; -ok my $req = POST $c->uri_for_action('/test_json'), - Content_Type => 'application/json', - Content => $post; - -ok my $response = request $req, 'got a response from a catalyst controller'; -is $response->content, $message, 'expected content body'; + +{ + ok my $message = 'helloworld'; + ok my $post = encode_json +{message=>$message}; + ok my $req = POST $c->uri_for_action('/test_json'), + Content_Type => 'application/json', + Content => $post; + + ok my $response = request $req, 'got a response from a catalyst controller'; + is $response->content, $message, 'expected content body'; +} + +{ + ok my $req = POST $c->uri_for_action('/test_nested_for'), [ 'nested.value' => 'expected' ]; + ok my $response = request $req, 'got a response from a catalyst controller'; + is $response->content, 'expected', 'expected content body'; +} + +{ + my $out; + local *STDERR; + open(STDERR, ">", \$out) or die "Can't open STDERR: $!"; + ok my $req = POST $c->uri_for_action('/test_nested_for'), 'Content-Type' => 'multipart/form-data', Content => { die => "a horrible death" }; + ok my $response = request $req; + is($out, "[error] multipart/form-data does not have an available data handler. Valid data_handlers are application/json, application/x-www-form-urlencoded.\n", 'yep we throw the slightly more usefull error'); +} done_testing;