frostman has asked for the wisdom of the Perl Monks concerning the following question:
O wise and busy monks, I find myself pulling out valuable hair once again, and come seeking respite and enlightenment.
I'm writing something that will bake and eat cookies in an Apache2/mod_perl2 environment (environment2?) using HTML::Mason. After a bit of wrestling I got Apache2::Cookie and the rest of the libapreq2 things installed.
But now I can't figure out how to test this stuff. The documentation features a mysterious $r, who is supposed to be an Apache2::RequestRec. But then:
$ perl -MApache2::RequestRec -e 'Apache2::RequestRec->new()' Can't locate object method "new" via package "Apache2::RequestRec" at +-e line 1.
Well, maybe there's just another constructor. But I can't find it, and the docs for Apache::RequestUtil actually say that's supposed to work:
new Create a new Apache2::RequestRec object. $r = Apache2::RequestRec->new($c); $r = Apache2::RequestRec->new($c, $pool);
I understand that the $r is, in a running server, automagically provided by mod_perl2. But it seems like a Very Bad Idea ™ to have a running apache2/mod_perl2 system be a prerequisite for unit-testing your cookie recipes, so perhaps I'm just unclear on the concept.
The test I want to run, by the way, would look something like this in its most minimal form:
use strict; use warnings; use Test::More tests => 1; use Apache2::Cookie 2.08; use Apache2::RequestRec 2.0; use Apache2::RequestUtil 2.0; # This, of course, doesn't work: my $r = Apache2::RequestRec->new(); # This is straight out of the synopsis, # but where do I get that blasted $r? my $cookie = Apache2::Cookie->new( $r, -name => "mycookie", -value => "whatever" ); isa_ok( $cookie, 'Apache2::Cookie' );
As much as I'd like to sit around and complain about the mystery meat in that documentation, I have to actually get this thing done, and I believe my options are:
What, dear Monks, would you recommend, and have any of you faced similar troubles in the past?
|
|---|