[Catalyst] Test::WWW::Mechanize::Catalyst and is_base()

Chisel Wright chisel at herlpacker.co.uk
Tue Nov 6 21:32:12 GMT 2007

I've recently started Doing The Right Thing and have starting fleshing
out the test suite for one of my projects.

In the last day or three I've added Test::WWW::Mechanize::Catalyst based

I seem to be having a problem with the value set for <base> in the
tests; I'm using:

  <base href="[%c.req.base%]" />

and all of my links are of the form:

  <a href="somewhere/interesting">...</a>

When I run the foo_server.pl script, viewing the page source reveals
that the <base> is (as expected) set to 'http://localhost:3000'.

When I'm running Mechanize based tests the base appears to always be set
to the URL that's being requested. This causes problems with things like

I've had no day-to-day problems using <base> and relative hrefs; I went
this route because I didn't want to have to add [%c.req.base%] to
_every_ URL in the app.

It's fairly easy to reproduce with a small catalyst application, and
I've all written a test for Test::WWW::Mechanize::Catalyst that
demonstrates the behaviour I'm having trouble with.
I don't know where the problem originates, but this seemed to be the
easiest place to demonstrate it.

As far as I can tell, all of the relevant modules are up-to-date:
  Module  = Test::WWW::Mechanize (PETDANCE/Test-WWW-Mechanize-1.16.tar.gz)
  Module  = Test::WWW::Mechanize::Catalyst (LBROCARD/Test-WWW-Mechanize-Catalyst-0.41.tar.gz)
  Module  = WWW::Mechanize (PETDANCE/WWW-Mechanize-1.32.tar.gz)
  Module  = Catalyst (MRAMBERG/Catalyst-Runtime-5.7011.tar.gz)

Also all /^Catalyst/ extras are up-to-date.

Does anyone have any idea if this is a bug, or if I'm just going about
things the wrong way?


---- cut here ----
$ catalyst.pl BaseTag
$ ./script/basetag_create.pl controller Lemon
$ ./script/basetag_create.pl view TT TT
$ vi lib/BaseTag/Controller/Lemon.pm

sub juice :Local {
    my ($self, $c) = @_;

$ mkdir -p root/base/lemon
$ vi root/base/lemon/juice.tt

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

        <base href="[%c.req.base%]" />

$ vi t/00.base.t

use Test::More tests => 3;
use_ok( 'Test::WWW::Mechanize::Catalyst', 'BaseTag' );
my $mech = Test::WWW::Mechanize::Catalyst->new;
$mech->get_ok("http://localhost/lemon/juice", 'Got lemon/juice');

$ CATALYST_DEBUG=0 ./script/basetag_test.pl /lemon/juice |grep '<base'
        <base href="http://localhost/" />

$ CATALYST_DEBUG=0 prove -l ./t/00.base.t
./t/00.base....ok 1/3                                                        
#   Failed test at ./t/00.base.t line 5.
#          got: "http://localhost/lemon/juice"
#       length: 28
#     expected: "http://localhost/"
#       length: 17
#     strings begin to differ at char 18
./t/00.base....NOK 3/3# Looks like you failed 1 test of 3.                   
        Test returned status 1 (wstat 256, 0x100)
        Failed 1/3 tests, 66.67% okay
Failed Test   Stat Wstat Total Fail  List of Failed
./t/00.base.t    1   256     3    1  3
Failed 1/1 test scripts. 1/3 subtests failed.
Files=1, Tests=3,  1 wallclock secs ( 1.07 cusr +  0.15 csys =  1.22 CPU)
Failed 1/1 test programs. 1/3 subtests failed.
---- cut here ----
Chisel Wright
e: chisel at herlpacker.co.uk
w: http://www.herlpacker.co.uk/

  It's like ingenuity wrapped in stupidity wrapped in a function.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug-base-tag.t
Type: application/x-troff
Size: 397 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071106/616d21e8/bug-base-tag.t

More information about the Catalyst mailing list