CatalystX-I18N

 view release on metacpan or  search on metacpan

t/testlib.pm  view on Meta::CPAN

package testlib;

use lib qw(t/testapp/lib);
use warnings;
use strict;

use Test::Most;
use JSON;
use Test::WWW::Mechanize::Catalyst;


sub import {
    my ($class) = @_;
    my $caller = scalar caller();

    strict->import;
    warnings->import;
    
    no strict 'refs';
    *{$caller.'::init'}=\&init;
    *{$caller.'::request'}=\&request;

}

sub init {
    return Test::WWW::Mechanize::Catalyst->new(
        catalyst_app => 'TestApp',
        cookie_jar => {},
    );
}

sub request {
    my ($mech) = shift;
    
    $mech->get_ok(@_);
    
    my $response = eval {
        return decode_json($mech->content);
    };
    if (! $response || $@) {
        fail('Could not parse JSON: '.$mech->content);
    } else {
        pass('JSON ok');
    }
    return $response;
}

1;



( run in 0.719 second using v1.01-cache-2.11-cpan-71847e10f99 )