[Catalyst] getting $c in model unit test

Matt Lawrence matt.lawrence at ymogen.net
Fri May 18 10:23:07 GMT 2007


Matt S Trout wrote:
> Erm. I was more thinking returning it after a prepare but with ->req popu=
lated.
>
> The idea for me would be for unit testing controllers/views (and any mode=
l code
> that uses ACCEPT_CONTEXT).
>
> Of course, if you wanted you could then call ->dispatch and then ->finali=
ze
> yourself, but once you're getting as far as that you're probably better u=
sing
> the standard stuff (plus replacing the view with a mock one via
> $c->_components->{MyApp::View::Foo} =3D $test_view to handle testing just=
 the
> controller ops and stash contents)
>   =


Fair enough. Sounds like a plan. Looks like it would be almost the same
as Catalyst::Test::request but calling prepare() instead of handle_request.

I've made a quick patch, minimally tested.

Matt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cat_test_context.patch
Type: text/x-patch
Size: 1164 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070518/1262=
e79c/cat_test_context-0001.bin


More information about the Catalyst mailing list