Actually fixing the version number (hopefully)
[catagits/Catalyst-Action-REST.git] / t / json.t
CommitLineData
7ad87df9 1use strict;
2use warnings;
d6fb033c 3use Test::More tests => 9;
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
17d910bd 11SKIP: {
d6fb033c 12 my $has_serializer = eval "require JSON::Syck";
13
14 skip "JSON::Syck not available", 8, unless $has_serializer;
17d910bd 15
d6fb033c 16 for ('text/x-json', 'application/json') {
17 my $t = Test::Rest->new('content_type' => $_);
18 my $monkey_template = {
19 monkey => 'likes chicken!',
20 };
21 my $mres = request($t->get(url => '/monkey_get'));
22 ok( $mres->is_success, 'GET the monkey succeeded' );
23 is_deeply(JSON::Syck::Load($mres->content), $monkey_template, "GET returned the right data");
17d910bd 24
d6fb033c 25 my $post_data = {
26 'sushi' => 'is good for monkey',
27 };
28 my $mres_post = request($t->post(url => '/monkey_put', data => JSON::Syck::Dump($post_data)));
29 ok( $mres_post->is_success, "POST to the monkey succeeded");
30 is_deeply($mres_post->content, "is good for monkey", "POST data matches");
31 }
7ad87df9 32};
7ad87df9 33
341;