Archive for November, 2009

Calling Catalyst functions outside Catalyst.

Monday, November 30th, 2009

Several times, I’ve wished I could write command-line tools to manage Catalyst applications.  Those tools, invariably, needed to call some of the Catalyst functions, or at least get to the database.

I had struggled with Config::JFDI and tried to create DBIx::Class objects outside of the Catalyst models so they could be used standalone.  This sort of worked, but wasn’t as easy as I wanted.

I found a way, and it’s so simple it hurts.   I can’t help think this is one of those things the Catalyst team will read and think, “Well, duh!” but it was never clear to me and I struggled with it for months. (more…)

Adding Actions to a Catalyst app at testing time

Sunday, November 15th, 2009

In response to a question I posted on the Catalyst list, Tomas Doran (among other suggestions) posted a beautifully devious way to add additional capabilites to your application for test purposes.

When you’re testing with Catalyst::Test and running a local test, you don’t actually fire up a web server and talk over the wire.  It loads your program’s library in to the test script, and calls the functions with the same objects given to it by the other servers.

Your Cat app runs, but all as functions in your program.

Since this is your program – and a test script is just a funny Perl program – you can load libraries and add additional things to the namespace.

Testing Catalyst Session Data

Sunday, November 15th, 2009

Tomas Doran pointed out the other day, in a post on the Catalyst mailing list, that you could manipulate the session data between test calls if you needed to.

My original question was about manipulating what user was logged by playing with the cookie cache, but it should apply to any value in the session.  You could check them, to see that the internal state of your program is what you think it is, or you could fiddle with them, to test that it does the right things.

Stealing From the Experts: Look at Their Tests!

Sunday, November 15th, 2009

I don’t know why this didn’t come to me quicker, but I got some good advice on the Catalyst mailing list.  It boils down to “look at how other people do it”, which I usually think of.

What I’d never thought of before was to look at their test cases for ways to do it.

Both Tomas Doran and Peter Karman made good suggestions of places to look for things that would help with my authentication issue.

Cookies and Catalyst::Test

Sunday, November 15th, 2009

The other day, I asked a question over on the Catalyst mailing list which spurred on some discussion.  Some of that discussion showed up with an example of how to check for cookines on the result of a Catalyst::Test operation.

There seems to be a way to jigger it in, but adding some real support for it might be better. Others seemed to agree.

How?  What’s best?

generic viagra in british columbia Order Viagra can i take viagra