r48@latte: adam | 2006-12-03 11:32:40 -0800
[catagits/Catalyst-Action-REST.git] / t / 02-data-serializer.t
CommitLineData
7ad87df9 1use strict;
2use warnings;
3use Test::More qw(no_plan);
4use Data::Serializer;
5use FindBin;
6
7use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib");
8use Test::Rest;
9
10my $dso = Data::Serializer->new(serializer => 'Data::Dumper');
11
12# Should use Data::Dumper, via Data::Serializer
13my $t = Test::Rest->new('content_type' => 'text/x-data-dumper');
14
15BEGIN { use_ok 'Catalyst::Test', 'SampleREST' }
16
17my $mres = request($t->get(url => '/monkey'));
18# We should find the monkey
19ok( $mres->is_success, 'GET the monkey succeeded' );
20
21my $monkey_template = {
22 monkey => 'likes chicken!',
23};
24my $monkey_data = $dso->raw_deserialize($mres->content);
25is_deeply($monkey_data, $monkey_template, "GET returned the right data");
26
27my $post_data = {
28 'sushi' => 'is good for monkey',
29};
30my $mres_post = request($t->post(url => '/monkey', data => $dso->raw_serialize($post_data)));
31ok( $mres_post->is_success, "POST to the monkey succeeded");
32is_deeply($mres_post->content, $dso->raw_serialize($post_data), "POST data matches");
33
341;