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: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to