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