X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fjson.t;fp=t%2Fjson.t;h=2cbf35d77d62488ffa3005ce7703edc5b3c684ef;hb=8f00a41bd7efb75d302d0a333e0eb5bc7d75c931;hp=0000000000000000000000000000000000000000;hpb=e601addaf89882fccbc824c1a53328f0d049b32b;p=catagits%2FCatalyst-Action-REST.git diff --git a/t/json.t b/t/json.t new file mode 100644 index 0000000..2cbf35d --- /dev/null +++ b/t/json.t @@ -0,0 +1,32 @@ +use strict; +use warnings; +use Test::More qw(no_plan); +use FindBin; + +use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib"); +use Test::Rest; + +use_ok 'Catalyst::Test', 'Test::Serialize'; + +my $t = Test::Rest->new('content_type' => 'text/x-json'); + +my $has_serializer = eval "require JSON::Syck"; +SKIP: { + skip "JSON::Syck not available", 4, unless $has_serializer; + + my $monkey_template = { + monkey => 'likes chicken!', + }; + my $mres = request($t->get(url => '/monkey_get')); + ok( $mres->is_success, 'GET the monkey succeeded' ); + is_deeply(JSON::Syck::Load($mres->content), $monkey_template, "GET returned the right data"); + + my $post_data = { + 'sushi' => 'is good for monkey', + }; + my $mres_post = request($t->post(url => '/monkey_put', data => JSON::Syck::Dump($post_data))); + ok( $mres_post->is_success, "POST to the monkey succeeded"); + is_deeply($mres_post->content, "is good for monkey", "POST data matches"); +}; + +1;