FAQ
Hi all,

Sorry if this is a newbie question, I am having a problem writing a
basic test for Catalyst::Helper::View::TTSite generated code. I did
the following:

./script/myapp_create.pl view TT TTSite

which creates the following package:

package MyApp::View::TT;

use strict;
use base 'Catalyst::View::TT';

__PACKAGE__->config({
INCLUDE_PATH => [
MyApp->path_to( 'root', 'src' ),
MyApp->path_to( 'root', 'lib' )
],
PRE_PROCESS => 'config/main',
WRAPPER => 'site/wrapper',
ERROR => 'error.tt2',
TIMER => 0,
render_die => 1,
});

If I create a basic test for this t/view_TT.t that looks like this:

use strict;
use warnings;
use Test::More;

BEGIN { use_ok 'MyApp::View::TT' }

done_testing();

I get the following error when test:

# Failed test 'use MyApp::View::TT;'
# at t/view_TT.t line 5.
# Tried to use 'MyApp::View::TT'.
# Error: Can't locate object method "path_to" via package "MyApp"
at /home/lhermida/work/workspaces/catalyst/MyApp/lib/MyApp/View/TT.pm
line 6.

Is it because at compile time MyApp doesn't have the path_to() method?
How should I write the test?

not sure,
Leandro

Search Discussions

  • Kevin montuori at Jul 27, 2010 at 2:19 pm

    On Tue, Jul 27, 2010 at 10:07 AM, Leandro Hermida wrote:

    Is it because at compile time MyApp doesn't have the path_to() method?
    ?How should I write the test?
    Perhaps a 'use MyApp' statement?

    k.

    --
    kevin montuori
  • Leandro Hermida at Jul 27, 2010 at 2:26 pm

    On Tue, Jul 27, 2010 at 4:19 PM, kevin montuori wrote:
    On Tue, Jul 27, 2010 at 10:07 AM, Leandro Hermida
    wrote:
    Is it because at compile time MyApp doesn't have the path_to() method?
    ?How should I write the test?
    Perhaps a 'use MyApp' statement?
    Right, thanks Kevin! I did this in t/view_TT.t and everything works now:

    use strict;
    use warnings;
    use Test::More;

    BEGIN { use_ok 'MyApp', 'MyApp::View::TT' }

    done_testing();
    k.

    --
    kevin montuori

    _______________________________________________
    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/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJul 27, '10 at 2:07p
activeJul 27, '10 at 2:26p
posts3
users2
websitecatalystframework.org
irc#catalyst

2 users in discussion

Leandro Hermida: 2 posts Kevin montuori: 1 post

People

Translate

site design / logo © 2022 Grokbase