Re: [Catalyst] How to handle role checking using a MockObject for Catalyst contexts
On 13/08/12 21:17 Wallace Reis wrote: > On Aug 07, 2012, at 11:42 AM, Robert Rothenberg wrote: >>> Personally, latterly, I've just been using Moose directly when I want to >>> mock a class: >>> >>> Moose::Meta::Class->create(…. > > And I love MX::Declare syntax sugar over this. ;) > > Btw, there is another useful module out there: > > https://metacpan.org/module/CatalystX::Test::MockContext It's not very useful for me, since it only includes requests. I need logs and authentication methods. :( ___ List: Catalyst@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/
Re: [Catalyst] How to handle role checking using a MockObject for Catalyst contexts
On Aug 07, 2012, at 11:42 AM, Robert Rothenberg wrote: >> Personally, latterly, I've just been using Moose directly when I want to >> mock a class: >> >> Moose::Meta::Class->create(…. And I love MX::Declare syntax sugar over this. ;) Btw, there is another useful module out there: https://metacpan.org/module/CatalystX::Test::MockContext Cheers, -- Wallace Reis | wreis wall...@reis.me http://www.about.me/wallacereis ___ List: Catalyst@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/
Re: [Catalyst] How to handle role checking using a MockObject for Catalyst contexts
On 06/08/12 18:36 Tomas Doran wrote: > > 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 >> like >> >> $c->check_any_use_role(...) >> >> 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: > > Moose::Meta::Class->create(…. > > e.g. https://gist.github.com/199215 (from > http://bobtfish.livejournal.com/265829.html) > Thanks. That looks like a much better solution. Are there plans to make a CPAN module or include a mock context for tests in the Catalyst distro? ___ List: Catalyst@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/
Re: [Catalyst] How to handle role checking using a MockObject for Catalyst contexts
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 > like > > $c->check_any_use_role(...) > > 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: Moose::Meta::Class->create(…. e.g. https://gist.github.com/199215 (from http://bobtfish.livejournal.com/265829.html) Cheers t0m ___ List: Catalyst@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/
[Catalyst] How to handle role checking using a MockObject for Catalyst contexts
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 like $c->check_any_use_role(...) So, what are the best practices for generating a fake Catalyst context that is, for all intents, logged-in as a particular user? Regards, Rob ___ List: Catalyst@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/