Less crap in MANIFEST please
[catagits/Catalyst-Action-REST.git] / t / json.t
CommitLineData
7ad87df9 1use strict;
2use warnings;
2f7533ed 3use Test::More;
7ad87df9 4use FindBin;
5
6use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib");
7use Test::Rest;
8
8b010556 9eval 'use JSON 2.12';
10plan skip_all => 'Install JSON 2.12 or later to run this test' if ($@);
7ad87df9 11
2f7533ed 12plan tests => 9;
d6fb033c 13
2f7533ed 14use_ok 'Catalyst::Test', 'Test::Serialize';
17d910bd 15
2f7533ed 16my $json = JSON->new;
17# The text/x-json should throw a warning
18for ('text/x-json', 'application/json') {
19 my $t = Test::Rest->new('content_type' => $_);
20 my $monkey_template = {
21 monkey => 'likes chicken!',
22 };
23 my $mres = request($t->get(url => '/monkey_get'));
24 ok( $mres->is_success, 'GET the monkey succeeded' );
25 is_deeply($json->decode($mres->content), $monkey_template, "GET returned the right data");
17d910bd 26
2f7533ed 27 my $post_data = {
28 'sushi' => 'is good for monkey',
29 };
30 my $mres_post = request($t->post(url => '/monkey_put', data => $json->encode($post_data)));
31 ok( $mres_post->is_success, "POST to the monkey succeeded");
32 is_deeply($mres_post->content, "is good for monkey", "POST data matches");
33}
7ad87df9 34
351;