r55@latte: adam | 2006-12-03 16:09:26 -0800
[catagits/Catalyst-Action-REST.git] / t / json.t
CommitLineData
7ad87df9 1use strict;
2use warnings;
6646fdc2 3use Test::More tests => 5;
7ad87df9 4use FindBin;
5
6use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib");
7use Test::Rest;
8
17d910bd 9use_ok 'Catalyst::Test', 'Test::Serialize';
7ad87df9 10
e601adda 11my $t = Test::Rest->new('content_type' => 'text/x-json');
17d910bd 12
e601adda 13my $has_serializer = eval "require JSON::Syck";
17d910bd 14SKIP: {
e601adda 15 skip "JSON::Syck not available", 4, unless $has_serializer;
17d910bd 16
17d910bd 17 my $monkey_template = {
18 monkey => 'likes chicken!',
19 };
20 my $mres = request($t->get(url => '/monkey_get'));
21 ok( $mres->is_success, 'GET the monkey succeeded' );
e601adda 22 is_deeply(JSON::Syck::Load($mres->content), $monkey_template, "GET returned the right data");
17d910bd 23
24 my $post_data = {
25 'sushi' => 'is good for monkey',
26 };
e601adda 27 my $mres_post = request($t->post(url => '/monkey_put', data => JSON::Syck::Dump($post_data)));
17d910bd 28 ok( $mres_post->is_success, "POST to the monkey succeeded");
29 is_deeply($mres_post->content, "is good for monkey", "POST data matches");
7ad87df9 30};
7ad87df9 31
321;