Acme-CatalystX-ILoveDebug
view release on metacpan or search on metacpan
---
abstract: 'Make all uris generated by an application trigger the debug page.'
author:
- 'Tomas Doran (t0m) C<< <bobtfish@bobtfish.net> >>.'
build_requires:
Catalyst::Runtime: 5.80015
ExtUtils::MakeMaker: 6.42
Test::More: 0.88
Test::WWW::Mechanize::Catalyst: 0
configure_requires:
ExtUtils::MakeMaker: 6.42
distribution_type: module
NAME
Acme::CatalystX::ILoveDebug - Make all uris generated by an application
trigger the debug page.
DESCRIPTION
Frivolous Catalyst application class role to demonstrate a trivial
application class role.
METHODS
uri_for
Wraps the normal uri_for call, injecting a parameter of "dump_info => 1"
into the call so that all URIs generated will cause the debug screen..
AUTHOR
Tomas Doran (t0m) "<bobtfish@bobtfish.net>".
COPYRIGHT & LICENSE
Copyright 2009 the above author(s).
This sofware is free software, and is licensed under the same terms as
perl itself.
lib/Acme/CatalystX/ILoveDebug.pm view on Meta::CPAN
my ($orig, $self) = (shift, shift);
my $params = ref($_[-1]) eq 'HASH' ? pop @_ : {};
$params->{dump_info} = 1;
$self->$orig(@_, $params);
};
1;
=head1 NAME
Acme::CatalystX::ILoveDebug - Make all uris generated by an application trigger the debug page.
=head1 DESCRIPTION
Frivolous L<Catalyst> application class role to demonstrate a trivial application class role.
=head1 METHODS
=head2 uri_for
Wraps the normal uri_for call, injecting a parameter of C<< dump_info => 1 >>
into the call so that all URIs generated will cause the debug screen..
=head1 AUTHOR
Tomas Doran (t0m) C<< <bobtfish@bobtfish.net> >>.
=head1 COPYRIGHT & LICENSE
Copyright 2009 the above author(s).
This sofware is free software, and is licensed under the same terms as perl itself.
t/lib/TestApp/Controller/Root.pm view on Meta::CPAN
}
sub foo : Chained('base') PathPart('foo') Args(1) {
my ($self, $ctx, $arg) = @_;
is $arg, 222, 'Arg is 222 in foo';
$ctx->res->body($ctx->uri_for($self->action_for('foo'), 333, { bar => 'baz'}));
}
sub end : Action {
my ($self, $ctx) = @_;
die("ERK") if $ctx->req->parameters->{dump_info} && $ctx->debug;
}
__PACKAGE__->meta->make_immutable;
t/live-test.t view on Meta::CPAN
use warnings;
use Test::More;
# setup library path
use FindBin qw($Bin);
use lib "$Bin/lib";
use Catalyst::Test 'TestApp';
{
local *TestApp::debug = sub { 0 };
my $res = request('/');
ok $res->is_success;
like $res->content, qr/dump_info=1/;
ok request($res->content)->is_success;
}
{
local *TestApp::debug = sub { 1 };
my $res = request('/');
ok $res->is_success;
like $res->content, qr/dump_info=1/;
ok !request($res->content)->is_success;
}
{
local *TestApp::debug = sub { 0 };
my $res = request('/foo/222');
ok $res->is_success, 'success';
like $res->content, qr/dump_info=1/;
like $res->content, qr/bar=baz/;
}
done_testing;
( run in 1.145 second using v1.01-cache-2.11-cpan-49f99fa48dc )