use
lib
"$FindBin::Bin/lib"
;
use_ok
'Mojolicious::Plugin::REST'
;
my
$t
= Test::Mojo->new(
'MyRest'
);
$t
->get_ok(
'/api/v1/dogs'
)->status_is(200)
->json_is( {
data
=> [ {
id
=> 1,
name
=>
'bo'
}, {
id
=> 2,
name
=>
'boo'
} ] } );
$t
->post_ok(
'/api/v1/dogs'
=>
json
=> {
id
=> 3,
name
=>
'bu'
} )->status_is(200)
->json_is( {
data
=> {
id
=> 3,
name
=>
'bu'
} } );
$t
->get_ok(
'/api/v1/dogs/1'
)->status_is(200)->json_is( {
data
=> {
id
=> 1,
name
=>
'bo'
} } );
$t
->put_ok(
'/api/v1/dogs/1'
=>
json
=> {
name
=>
'bu'
} )->status_is(200)
->json_is( {
data
=> {
id
=> 1,
name
=>
'bu'
} } );
$t
->delete_ok(
'/api/v1/dogs/1'
)->status_is(200)->json_is( {
data
=> {
id
=> 1,
name
=>
'bo'
} } );
done_testing;