[Catalyst] testing catalyst app - need context

Jason Galea lists at eightdegrees.com.au
Mon Mar 2 02:06:26 GMT 2009


Hi Kate,

have a look at 
http://search.cpan.org/~jkutej/Catalyst-Plugin-CommandLine-0.05/lib/Catalyst/Plugin/CommandLine.pm

I've only used it once or twice and I don't know if it's considered 
"best practice" or not but it worked for me.. (I wanted easy access to 
Catalyst app config)

cheers,

J

package MyApp;
use Catalyst qw/ CommandLine /;


package main;
use MyApp;
my $c = MyApp->commandline;

my $acc = $c->model('Account')->find(1);



Kate Yoak wrote:
> Hi there,
>
>
> Here is a newbie question:
>
> I like to test my functionality in bits and pieces as I write it.  How
> do I go about getting myself the context object in a test script?
>
> For example, one of the tests catalyst installs is t/model_App.t where
> it loads the model.  I'd love to then be able to use the model the same
> way a controller would:
>
> my $acc = $c->model('Account')->find(1);
>
> Instead, I am doing 
>
> my $model = MyApp::Model::App->new();
> my $acc = $model->recordset('Account')->find(1);
>
> In addition to being less than ideal because I am doing something
> different that I expect real application code to do, it presents
> configuration problems.  Like, turns out, in order for config to take
> effect, I have to run __PACKAGE__->setup; after configuring it - which
> won't be necessary, I think, in a real app.
>
> Is the practice of unit tests that break up the layers of catalyst
> frowned upon? Or what should I do to make it work right?
>
>
>
> Thanks for the help!
> Cheers,
> Kate
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>   



More information about the Catalyst mailing list