Commit | Line | Data |
7ad87df9 |
1 | use strict; |
2 | use warnings; |
6646fdc2 |
3 | use Test::More tests => 5; |
7ad87df9 |
4 | use FindBin; |
e601adda |
5 | use Data::Dump qw(dump); |
7ad87df9 |
6 | |
7 | use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib"); |
8 | use Test::Rest; |
9 | |
17d910bd |
10 | use_ok 'Catalyst::Test', 'Test::Serialize'; |
7ad87df9 |
11 | |
e601adda |
12 | my $t = Test::Rest->new('content_type' => 'text/xml'); |
17d910bd |
13 | |
e601adda |
14 | my $has_serializer = eval "require XML::Simple"; |
17d910bd |
15 | SKIP: { |
e601adda |
16 | skip "XML::Simple not available", 4, unless $has_serializer; |
17 | |
18 | my $xs = XML::Simple->new('ForceArray' => 0); |
17d910bd |
19 | |
17d910bd |
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' ); |
e601adda |
25 | my $output = $xs->XMLin($mres->content); |
26 | is_deeply($xs->XMLin($mres->content)->{'data'}, $monkey_template, "GET returned the right data"); |
17d910bd |
27 | |
28 | my $post_data = { |
29 | 'sushi' => 'is good for monkey', |
30 | }; |
e601adda |
31 | my $mres_post = request($t->post(url => '/monkey_put', data => $xs->XMLout($post_data))); |
17d910bd |
32 | ok( $mres_post->is_success, "POST to the monkey succeeded"); |
33 | is_deeply($mres_post->content, "is good for monkey", "POST data matches"); |
7ad87df9 |
34 | }; |
7ad87df9 |
35 | |
36 | 1; |