Created
November 4, 2013 14:12
-
-
Save moznion/7303022 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use HTTP::Request::Common; | |
use JSON qw/to_json/; | |
use Plack::Test; | |
use Test::More; | |
use Test::JsonAPI::Autodoc; | |
# PSGI application | |
my $app = sub { | |
my $json = to_json({ | |
jsonrpc => '2.0', | |
result => { | |
entries => [{ | |
title => 'example', | |
body => 'Hello!', | |
}], | |
}, | |
id => 1, | |
}); | |
return [ 200, [ 'Content-Type' => 'application/json' ], [$json] ]; | |
}; | |
my $test_app = Plack::Test->create($app); | |
describe 'POST /' => sub { | |
my $json = to_json({ | |
jsonrpc => '2.0', | |
method => 'get_entries', | |
params => { limit => 1, category => 'technology' }, | |
}); | |
my $req = POST '/'; | |
$req->header('Content-Type' => 'application/json'); | |
$req->header('Content-Length' => length $json); | |
$req->content($json); | |
plack_ok($test_app, $req, 200, "get message ok"); | |
}; | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment