Skip to content

@jberger /json_like.pl
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
json_like for Test::Mojo
#!/usr/bin/env perl
use Test::More;
use Test::Mojo;
use Mojolicious::Lite;
my $json_like = sub {
my ($t, $p, $regex, $desc) = @_;
$desc ||= "json_like $regex";
local $Test::Builder::Level = $Test::Builder::Level + 1;
$t->success( like( $t->tx->res->json($p), $regex, $desc ) );
};
any '/' => sub {
shift->render( json => { quote => 'Why not Zoidberg?' } );
};
my $t = Test::Mojo->new;
$t->get_ok('/')
->$json_like( '/quote' => qr/Zoidberg/ )
->or(sub{ diag 'I guess not Zoidberg' });
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.