Amon2-Plugin-Web-ChromeLogger

 view release on metacpan or  search on metacpan

t/01_basic.t  view on Meta::CPAN

            );
        }
        elsif ($c->request->path_info =~ m!^/console$!) {
            $c->chrome('kai!');
            return $c->create_response(
                200,
                [],
                ['kai'],
            );
        }
        return $c->create_response(404, [], []);
    }
    __PACKAGE__->load_plugins('Web::ChromeLogger');
}

my $mech = Test::WWW::Mechanize::PSGI->new(app => MyApp::Web->to_app);

{
    $mech->get_ok('/info');
    $mech->content_contains('aloha');
    my $chrome_log = $mech->res->header('X-ChromeLogger-Data');

t/02_disabled.t  view on Meta::CPAN

    sub dispatch {
        my $c = shift;
        if ($c->request->path_info =~ m!^/disabled$!) {
            eval { $c->chrome_logger->info('aloha!'); };
            return $c->create_response(
                200,
                [],
                [$@],
            );
        }
        return $c->create_response(404, [], []);
    }
    __PACKAGE__->load_plugins('Web::ChromeLogger' => { disabled => 1 });
}

my $mech = Test::WWW::Mechanize::PSGI->new(app => MyApp::Web->to_app);

{
    $mech->get_ok('/disabled');
    $mech->content_contains(qq|Can't locate object method "chrome_logger"|);
    is $mech->res->header('X-ChromeLogger-Data'), undef;

t/03_enable_in_production.t  view on Meta::CPAN

    sub dispatch {
        my $c = shift;
        if ($c->request->path_info =~ m!^/production$!) {
            eval { $c->chrome_logger->info('aloha!'); };
            return $c->create_response(
                200,
                [],
                [$@],
            );
        }
        return $c->create_response(404, [], []);
    }
    # PLACK_ENV: 'production', and this plugin is disabled.
    __PACKAGE__->load_plugins('Web::ChromeLogger');
}

my $mech = Test::WWW::Mechanize::PSGI->new(app => MyApp::Web->to_app);

{
    $mech->get_ok('/production');
    $mech->content_contains(qq|Can't locate object method "chrome_logger"|);

t/03_enable_in_production.t  view on Meta::CPAN

    sub dispatch {
        my $c = shift;
        if ($c->request->path_info =~ m!^/production$!) {
            $c->chrome_logger->info('aloha!');
            return $c->create_response(
                200,
                [],
                ['aloha'],
            );
        }
        return $c->create_response(404, [], []);
    }
    # PLACK_ENV: 'production', but this plugin is enabled with enable_in_production option.
    __PACKAGE__->load_plugins('Web::ChromeLogger' => { enable_in_production => 1 });
}

my $mech2 = Test::WWW::Mechanize::PSGI->new(app => MyApp2::Web->to_app);

{
    $mech2->get_ok('/production');
    $mech2->content_contains('aloha');

t/04_json_encoder.t  view on Meta::CPAN

    sub dispatch {
        my $c = shift;
        if ($c->request->path_info =~ m!^/json_encoder$!) {
            $c->chrome_logger->info('aloha!');
            return $c->create_response(
                200,
                [],
                ['aloha'],
            );
        }
        return $c->create_response(404, [], []);
    }
    __PACKAGE__->load_plugins('Web::ChromeLogger' => {
        json_encoder => JSON->new->ascii(1)->convert_blessed,
    });
}

my $mech = Test::WWW::Mechanize::PSGI->new(app => MyApp::Web->to_app);

{
    $mech->get_ok('/json_encoder');



( run in 3.077 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )