File: two-posts.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 (40 lines) | stat: -rw-r--r-- 666 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
35
36
37
38
39
40
use strict;
use warnings;

{
    package Foo;

    use Dancer;
    use Dancer::Plugin::REST;

    prepare_serializer_for_format;

    post '/foo.:format' => sub {
        return params;
    };

}

use Test::More;
use Dancer::ModuleLoader;

plan skip_all => 'tests require JSON' 
    unless Dancer::ModuleLoader->load('JSON');

plan tests => 2;

use Dancer::Test;
use HTTP::Headers;

my $head = HTTP::Headers->new;

$head->header("content-type" => "application/json");

for ( 1..2 ) {
    my $resp = dancer_response( 'POST' => '/foo.json', {
            body => '{"yin":"yang","foo":"bar"}',
            headers => $head,
    });

    like $resp->content, qr/yin/;
}