[Catalyst] How to handle role checking using a MockObject for
bobtfish at bobtfish.net
Mon Aug 6 17:36:08 GMT 2012
On 6 Aug 2012, at 15:56, Robert Rothenberg wrote:
> My application has a lot of tests scripts (and even some utility scripts)
> that create a Test::MockObject that imitates a Catalyst context.
> But it's largely a kluge, especially for handling authentication with things
> So, what are the best practices for generating a fake Catalyst context that
> is, for all intents, logged-in as a particular user?
Test::MockObject is fairly evil (it uses UNIVERSAL::can and UNIVERSAL::isa which are fundamentally broken).. But this solution is entirely workable.
Personally, latterly, I've just been using Moose directly when I want to mock a class:
e.g. https://gist.github.com/199215 (from http://bobtfish.livejournal.com/265829.html)
More information about the Catalyst