Add tests which should fail, but don't.
[catagits/Catalyst-Action-REST.git] / t / yaml.t
1 use strict;
2 use warnings;
3 use Test::More tests => 5; 
4 use FindBin;
5
6 use lib ("$FindBin::Bin/lib", "$FindBin::Bin/../lib");
7 use Test::Rest;
8
9 use_ok 'Catalyst::Test', 'Test::Serialize';
10
11 # Should use the default serializer, YAML
12 my $t = Test::Rest->new('content_type' => 'text/x-yaml');
13
14 my $has_serializer = eval "require YAML::Syck";
15 SKIP: {
16     skip "YAML::Syck not available", 4, unless $has_serializer;
17
18     # We should use the default serializer, YAML
19     my $monkey_template = {
20         monkey => 'likes chicken!',
21     };
22     my $mres = request($t->get(url => '/monkey_get'));
23     ok( $mres->is_success, 'GET the monkey succeeded' );
24     is_deeply(YAML::Syck::Load($mres->content), $monkey_template, "GET returned the right data");
25
26     my $post_data = {
27         'sushi' => 'is good for monkey',
28     };
29     my $mres_post = request($t->post(url => '/monkey_put', data => YAML::Syck::Dump($post_data)));
30     ok( $mres_post->is_success, "POST to the monkey succeeded");
31     is_deeply($mres_post->content, "is good for monkey", "POST data matches");
32 };
33
34 1;