File: default-serializer.t

package info (click to toggle)
libdancer-plugin-rest-perl 0.11-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 172 kB
  • sloc: perl: 151; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 664 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;

use Test::More;

plan skip_all => 'XML::Simple required'
    unless eval "use XML::Simple; 1";

plan tests => 3;

{
    use Dancer ':tests';
    use Dancer::Plugin::REST;

    prepare_serializer_for_format;
    set serializer => 'XML';

    get '/foo' => sub {
        return { hello => 'world' };
    };

    get '/foo.:format' => sub {
        return { hello => 'world' };
    };

}

use Dancer::Test;

response_content_like '/foo' => qr/<data/, "default serializer is XML";

response_content_like '/foo.json' => qr/"hello"\s*:\s*"world"/, "ask for JSON";

response_content_like '/foo' => qr/<data/, "default serializer is still XML";