Fixed debug log, sort params before output
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Helper.pm
CommitLineData
fc7ec1d9 1package Catalyst::Helper;
2
3use strict;
4use base 'Class::Accessor::Fast';
f1d0b7ea 5use Config;
fc7ec1d9 6use File::Spec;
7use File::Path;
8use IO::File;
9use FindBin;
61cfdd57 10use Template;
2a276acb 11use Catalyst;
61cfdd57 12
13my %cache;
fc7ec1d9 14
15=head1 NAME
16
17Catalyst::Helper - Bootstrap a Catalyst application
18
19=head1 SYNOPSIS
20
21See L<Catalyst::Manual::Intro>
22
23=head1 DESCRIPTION
24
b160463f 25Bootstrap a Catalyst application. Autogenerates scripts
fc7ec1d9 26
27=head2 METHODS
28
61cfdd57 29=head3 get_file
30
31Slurp file from DATA.
32
33=cut
34
35sub get_file {
36 my ( $self, $class, $file ) = @_;
37 unless ( $cache{$class} ) {
38 local $/;
39 $cache{$class} = eval "package $class; <DATA>";
40 }
41 my $data = $cache{$class};
42 my @files = split /^__(.+)__\n/m, $data;
43 shift @files;
44 while (@files) {
45 my ( $name, $content ) = splice @files, 0, 2;
46 return $content if $name eq $file;
47 }
48 return 0;
49}
50
fc7ec1d9 51=head3 mk_app
52
b160463f 53Create the main application skeleton.
54
fc7ec1d9 55=cut
56
57sub mk_app {
58 my ( $self, $name ) = @_;
59 return 0 if $name =~ /[^\w\:]/;
60 $self->{name} = $name;
61 $self->{dir} = $name;
62 $self->{dir} =~ s/\:\:/-/g;
61cfdd57 63 $self->{startperl} = $Config{startperl};
2a276acb 64 $self->{scriptgen}=$Catalyst::CATALYST_SCRIPT_GEN;
ddb46924 65 $self->{author}=$self->{author} = $ENV{'AUTHOR'} ||
66 @{[getpwuid($<)]}[6];
fc7ec1d9 67 $self->_mk_dirs;
68 $self->_mk_appclass;
69 $self->_mk_makefile;
91864987 70 $self->_mk_readme;
71 $self->_mk_changes;
fc7ec1d9 72 $self->_mk_apptest;
bc024080 73 $self->_mk_cgi;
cb8d90e5 74 $self->_mk_fcgi;
fc7ec1d9 75 $self->_mk_server;
76 $self->_mk_test;
77 $self->_mk_create;
78 return 1;
79}
80
ad41e777 81=head3 mk_component
82
b160463f 83This method is called by create.pl to make new components
84for your application.
85
ad41e777 86=cut
87
88sub mk_component {
b5524568 89 my $self = shift;
90 my $app = shift;
91 $self->{app} = $app;
ddb46924 92 $self->{author}=$self->{author} = $ENV{'AUTHOR'} ||
93 @{[getpwuid($<)]}[6];
b5524568 94 $self->{base} = File::Spec->catdir( $FindBin::Bin, '..' );
95 unless ( $_[0] =~ /^model|m|view|v|controller|c\$/i ) {
96 my $helper = shift;
97 my @args = @_;
98 my $class = "Catalyst::Helper::$helper";
ad41e777 99 eval "require $class";
100 die qq/Couldn't load helper "$class", "$@"/ if $@;
b5524568 101 if ( $class->can('mk_stuff') ) {
102 return 1 unless $class->mk_stuff( $self, @args );
ad41e777 103 }
ad41e777 104 }
ad41e777 105 else {
b5524568 106 my $type = shift;
107 my $name = shift;
108 my $helper = shift;
109 my @args = @_;
110 return 0 if $name =~ /[^\w\:]/;
111 $type = 'M' if $type =~ /model|m/i;
112 $type = 'V' if $type =~ /view|v/i;
113 $type = 'C' if $type =~ /controller|c/i;
114 $self->{type} = $type;
115 $self->{name} = $name;
116 $self->{class} = "$app\::$type\::$name";
117
118 # Class
119 my $appdir = File::Spec->catdir( split /\:\:/, $app );
120 my $path =
121 File::Spec->catdir( $FindBin::Bin, '..', 'lib', $appdir, $type );
122 my $file = $name;
123 if ( $name =~ /\:/ ) {
124 my @path = split /\:\:/, $name;
125 $file = pop @path;
126 $path = File::Spec->catdir( $path, @path );
127 mkpath $path;
128 }
129 $file = File::Spec->catfile( $path, "$file.pm" );
130 $self->{file} = $file;
131
132 # Test
133 $self->{test_dir} = File::Spec->catdir( $FindBin::Bin, '..', 't' );
134 $self->{test} = $self->next_test;
135
136 # Helper
137 if ($helper) {
138 my $comp = 'Model';
139 $comp = 'View' if $type eq 'V';
140 $comp = 'Controller' if $type eq 'C';
141 my $class = "Catalyst::Helper::$comp\::$helper";
142 eval "require $class";
143 die qq/Couldn't load helper "$class", "$@"/ if $@;
144 if ( $class->can('mk_compclass') ) {
145 return 1 unless $class->mk_compclass( $self, @args );
146 }
147 else { return 1 unless $self->_mk_compclass }
148
149 if ( $class->can('mk_comptest') ) {
150 $class->mk_comptest( $self, @args );
151 }
152 else { $self->_mk_comptest }
153 }
154
155 # Fallback
156 else {
157 return 1 unless $self->_mk_compclass;
158 $self->_mk_comptest;
159 }
ad41e777 160 }
161 return 1;
162}
163
164=head3 mk_dir
165
b160463f 166Surprisingly, this function makes a directory.
167
ad41e777 168=cut
169
170sub mk_dir {
171 my ( $self, $dir ) = @_;
172 if ( -d $dir ) {
173 print qq/ exists "$dir"\n/;
174 return 0;
175 }
176 if ( mkpath $dir) {
177 print qq/created "$dir"\n/;
178 return 1;
179 }
180 die qq/Couldn't create "$dir", "$!"/;
181}
182
183=head3 mk_file
184
b160463f 185writes content to a file.
186
ad41e777 187=cut
188
189sub mk_file {
190 my ( $self, $file, $content ) = @_;
191 if ( -e $file ) {
192 print qq/ exists "$file"\n/;
193 return 0;
194 }
195 if ( my $f = IO::File->new("> $file") ) {
196 print $f $content;
197 print qq/created "$file"\n/;
198 return 1;
199 }
200 die qq/Couldn't create "$file", "$!"/;
201}
202
203=head3 next_test
204
205=cut
206
207sub next_test {
208 my ( $self, $tname ) = @_;
3cb1db8c 209 if ($tname) { $tname = "$tname.t" }
ad41e777 210 else {
211 my $name = $self->{name};
ad41e777 212 my $prefix = $name;
213 $prefix =~ s/::/_/g;
214 $prefix = lc $prefix;
3cb1db8c 215 $tname = $prefix . '.t';
ad41e777 216 $self->{prefix} = $prefix;
217 }
3cb1db8c 218 my $dir = $self->{test_dir};
219 my $type = lc $self->{type};
220 return File::Spec->catfile( $dir, $type, $tname );
ad41e777 221}
222
61cfdd57 223=head3 render_file
224
b160463f 225Render and create a file from a template in DATA using
226Template Toolkit.
61cfdd57 227
228=cut
229
230sub render_file {
231 my ( $self, $file, $path, $vars ) = @_;
232 $vars ||= {};
233 my $t = Template->new;
234 my $template = $self->get_file( ( caller(0) )[0], $file );
235 return 0 unless $template;
236 my $output;
237 $t->process( \$template, { %{$self}, %$vars }, \$output );
238 $self->mk_file( $path, $output );
239}
240
fc7ec1d9 241sub _mk_dirs {
242 my $self = shift;
ad41e777 243 $self->mk_dir( $self->{dir} );
91864987 244 $self->{script} = File::Spec->catdir( $self->{dir}, 'script' );
245 $self->mk_dir( $self->{script} );
fc7ec1d9 246 $self->{lib} = File::Spec->catdir( $self->{dir}, 'lib' );
ad41e777 247 $self->mk_dir( $self->{lib} );
fc7ec1d9 248 $self->{root} = File::Spec->catdir( $self->{dir}, 'root' );
ad41e777 249 $self->mk_dir( $self->{root} );
fc7ec1d9 250 $self->{t} = File::Spec->catdir( $self->{dir}, 't' );
ad41e777 251 $self->mk_dir( $self->{t} );
3cb1db8c 252 $self->mk_dir( File::Spec->catdir( $self->{t}, 'm' ) );
253 $self->mk_dir( File::Spec->catdir( $self->{t}, 'v' ) );
254 $self->mk_dir( File::Spec->catdir( $self->{t}, 'c' ) );
fc7ec1d9 255 $self->{class} = File::Spec->catdir( split( /\:\:/, $self->{name} ) );
256 $self->{mod} = File::Spec->catdir( $self->{lib}, $self->{class} );
ad41e777 257 $self->mk_dir( $self->{mod} );
fc7ec1d9 258 $self->{m} = File::Spec->catdir( $self->{mod}, 'M' );
ad41e777 259 $self->mk_dir( $self->{m} );
fc7ec1d9 260 $self->{v} = File::Spec->catdir( $self->{mod}, 'V' );
ad41e777 261 $self->mk_dir( $self->{v} );
fc7ec1d9 262 $self->{c} = File::Spec->catdir( $self->{mod}, 'C' );
ad41e777 263 $self->mk_dir( $self->{c} );
fc7ec1d9 264 $self->{base} = File::Spec->rel2abs( $self->{dir} );
265}
266
267sub _mk_appclass {
ad41e777 268 my $self = shift;
269 my $mod = $self->{mod};
61cfdd57 270 $self->render_file( 'appclass', "$mod.pm" );
271}
272
273sub _mk_makefile {
274 my $self = shift;
275 my $dir = $self->{dir};
276 $self->render_file( 'makefile', "$dir\/Makefile.PL" );
277}
278
279sub _mk_readme {
280 my $self = shift;
281 my $dir = $self->{dir};
282 $self->render_file( 'readme', "$dir\/README" );
283}
284
285sub _mk_changes {
286 my $self = shift;
287 my $dir = $self->{dir};
288 my $time = localtime time;
289 $self->render_file( 'changes', "$dir\/Changes", { time => $time } );
290}
291
292sub _mk_apptest {
293 my $self = shift;
294 my $t = $self->{t};
295 $self->render_file( 'apptest', "$t\/01app.t" );
296 $self->render_file( 'podtest', "$t\/02pod.t" );
297 $self->render_file( 'podcoveragetest', "$t\/03podcoverage.t" );
298}
299
300sub _mk_cgi {
301 my $self = shift;
302 my $script = $self->{script};
303 $self->render_file( 'cgi', "$script\/cgi.pl" );
304 chmod 0700, "$script/cgi.pl";
305}
306
307sub _mk_fcgi {
308 my $self = shift;
309 my $script = $self->{script};
310 $self->render_file( 'fcgi', "$script\/fcgi.pl" );
311 chmod 0700, "$script/fcgi.pl";
312}
313
314sub _mk_server {
315 my $self = shift;
316 my $script = $self->{script};
317 $self->render_file( 'server', "$script\/server.pl" );
318 chmod 0700, "$script/server.pl";
319}
320
321sub _mk_test {
322 my $self = shift;
323 my $script = $self->{script};
324 $self->render_file( 'test', "$script/test.pl" );
325 chmod 0700, "$script/test.pl";
326}
327
328sub _mk_create {
329 my $self = shift;
330 my $script = $self->{script};
331 $self->render_file( 'create', "$script\/create.pl" );
332 chmod 0700, "$script/create.pl";
333}
334
335sub _mk_compclass {
336 my $self = shift;
337 my $file = $self->{file};
338 return $self->render_file( 'compclass', "$file" );
339}
340
341sub _mk_comptest {
342 my $self = shift;
343 my $test = $self->{test};
344 $self->render_file( 'comptest', "$test" );
345}
346
347=head1 HELPERS
348
349Helpers are classes that provide two methods.
350
351 * mk_compclass - creates the Component class
352 * mk_comptest - creates the Component test
353
354So when you call C<bin/create view MyView TT>, create would try to execute
355Catalyst::Helper::View::TT->mk_compclass and
356Catalyst::Helper::View::TT->mk_comptest.
357
358See L<Catalyst::Helper::View::TT> and L<Catalyst::Helper::Model::CDBI> for
359examples.
360
361All helper classes should be under one of the following namespaces.
362
363 Catalyst::Helper::Model::
364 Catalyst::Helper::View::
365 Catalyst::Helper::Controller::
366
ddb46924 367=head1 NOTE
368
369The helpers will read author name from /etc/passwd by default.
370To override, please export the AUTHOR variable.
371
61cfdd57 372=head1 SEE ALSO
373
374L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
375L<Catalyst::Response>, L<Catalyst>
376
377=head1 AUTHOR
378
379Sebastian Riedel, C<sri@oook.de>
380
381=head1 LICENSE
382
b160463f 383This library is free software . You can redistribute it and/or modify
384it under the same terms as perl itself.
61cfdd57 385
386=cut
387
3881;
389__DATA__
390
391__appclass__
392package [% name %];
fc7ec1d9 393
394use strict;
395use Catalyst qw/-Debug/;
396
61cfdd57 397our $VERSION = '0.01';
fc7ec1d9 398
61cfdd57 399[% name %]->config(
400 name => '[% name %]',
401 root => '[% base %]/root',
fc7ec1d9 402);
5811fa3e 403
61cfdd57 404[% name %]->setup;
fc7ec1d9 405
5a8ed4fe 406sub default : Private {
61cfdd57 407 my ( $self, $c ) = @_;
408 $c->res->output('Congratulations, [% name %] is on Catalyst!');
5a8ed4fe 409}
fc7ec1d9 410
411=head1 NAME
412
61cfdd57 413[% name %] - A very nice application
fc7ec1d9 414
415=head1 SYNOPSIS
416
417 Very simple to use
418
419=head1 DESCRIPTION
420
421Very nice application.
422
423=head1 AUTHOR
424
ddb46924 425[%author%]
fc7ec1d9 426
427=head1 LICENSE
428
b160463f 429This library is free software . You can redistribute it and/or modify
430it under the same terms as perl itself.
fc7ec1d9 431
432=cut
433
4341;
fc7ec1d9 435
61cfdd57 436__makefile__
fc7ec1d9 437use ExtUtils::MakeMaker;
438
439WriteMakefile(
61cfdd57 440 NAME => '[% name %]',
441 VERSION_FROM => 'lib/[% class %].pm',
4400b5ef 442 PREREQ_PM => { Catalyst => 5 },
3cb1db8c 443 test => { TESTS => join ' ', ( glob('t/*.t'), glob('t/*/*.t') ) }
fc7ec1d9 444);
fc7ec1d9 445
61cfdd57 446__readme__
91864987 447Run script/server.pl to test the application.
91864987 448
61cfdd57 449__changes__
7a870961 450This file documents the revision history for Perl extension [% name %].
91864987 451
61cfdd57 4520.01 [% time %]
91864987 453 - initial revision, generated by Catalyst
91864987 454
61cfdd57 455__apptest__
fc7ec1d9 456use Test::More tests => 2;
61cfdd57 457use_ok( Catalyst::Test, '[% name %]' );
fc7ec1d9 458
459ok( request('/')->is_success );
61cfdd57 460
461__podtest__
5a8fd7e9 462use Test::More;
463
464eval "use Test::Pod 1.14";
61cfdd57 465plan skip_all => 'Test::Pod 1.14 required' if $@;
466plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
5a8fd7e9 467
468all_pod_files_ok();
61cfdd57 469
470__podcoveragetest__
1df125c9 471use Test::More;
472
473eval "use Test::Pod::Coverage 1.04";
61cfdd57 474plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
475plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
1df125c9 476
477all_pod_coverage_ok();
fc7ec1d9 478
195631f4 479__cgi__
61cfdd57 480[% startperl %] -w
481BEGIN { $ENV{CATALYST_ENGINE} = 'CGI' }
d8ab1b45 482
483use strict;
484use FindBin;
61cfdd57 485use lib "$FindBin::Bin/../lib";
486use [% name %];
d8ab1b45 487
61cfdd57 488[% name %]->run;
d8ab1b45 489
4901;
d8ab1b45 491
492=head1 NAME
493
494cgi - Catalyst CGI
495
496=head1 SYNOPSIS
497
498See L<Catalyst::Manual>
499
500=head1 DESCRIPTION
501
502Run a Catalyst application as cgi.
503
504=head1 AUTHOR
505
61cfdd57 506Sebastian Riedel, C<sri@oook.de>
d8ab1b45 507
508=head1 COPYRIGHT
509
510Copyright 2004 Sebastian Riedel. All rights reserved.
511
b160463f 512This library is free software. You can redistribute it and/or modify
513it under the same terms as perl itself.
d8ab1b45 514
515=cut
d8ab1b45 516
61cfdd57 517__fcgi__
518[% startperl %] -w
cb8d90e5 519
61cfdd57 520BEGIN { $ENV{CATALYST_ENGINE} = 'FCGI' }
cb8d90e5 521
522use strict;
523use FindBin;
61cfdd57 524use lib "$FindBin::Bin/../lib";
525use [% name %];
cb8d90e5 526
61cfdd57 527[% name %]->run;
cb8d90e5 528
5291;
cb8d90e5 530
531=head1 NAME
532
533fcgi - Catalyst FCGI
534
535=head1 SYNOPSIS
536
537See L<Catalyst::Manual>
538
539=head1 DESCRIPTION
540
541Run a Catalyst application as fcgi.
542
543=head1 AUTHOR
544
61cfdd57 545Sebastian Riedel, C<sri@oook.de>
cb8d90e5 546
547=head1 COPYRIGHT
548
549Copyright 2004 Sebastian Riedel. All rights reserved.
550
b160463f 551This library is free software. You can redistribute it and/or modify
552it under the same terms as perl itself.
cb8d90e5 553
554=cut
cb8d90e5 555
61cfdd57 556__server__
557[% startperl %] -w
fc7ec1d9 558
42a57832 559BEGIN {
560 $ENV{CATALYST_ENGINE} = 'HTTP';
561 $ENV{CATALYST_SCRIPT_GEN} = [% scriptgen %];
562}
585893b9 563
fc7ec1d9 564use strict;
565use Getopt::Long;
566use Pod::Usage;
567use FindBin;
61cfdd57 568use lib "$FindBin::Bin/../lib";
569use [% name %];
fc7ec1d9 570
61cfdd57 571my $help = 0;
572my $port = 3000;
fc7ec1d9 573
61cfdd57 574GetOptions( 'help|?' => \$help, 'port=s' => \$port );
fc7ec1d9 575
195631f4 576pod2usage(1) if $help;
fc7ec1d9 577
61cfdd57 578[% name %]->run($port);
fc7ec1d9 579
5801;
fc7ec1d9 581
582=head1 NAME
583
584server - Catalyst Testserver
585
586=head1 SYNOPSIS
587
91864987 588server.pl [options]
fc7ec1d9 589
590 Options:
ad41e777 591 -? -help display this help and exits
592 -p -port port (defaults to 3000)
fc7ec1d9 593
03a53815 594 See also:
595 perldoc Catalyst::Manual
596 perldoc Catalyst::Manual::Intro
597
fc7ec1d9 598=head1 DESCRIPTION
599
600Run a Catalyst Testserver for this application.
601
602=head1 AUTHOR
603
61cfdd57 604Sebastian Riedel, C<sri@oook.de>
fc7ec1d9 605
606=head1 COPYRIGHT
607
608Copyright 2004 Sebastian Riedel. All rights reserved.
609
b160463f 610This library is free software. You can redistribute it and/or modify
611it under the same terms as perl itself.
fc7ec1d9 612
613=cut
fc7ec1d9 614
61cfdd57 615__test__
616[% startperl %] -w
fc7ec1d9 617
61cfdd57 618BEGIN { $ENV{CATALYST_ENGINE} = 'Test' }
e646f111 619
fc7ec1d9 620use strict;
621use Getopt::Long;
622use Pod::Usage;
623use FindBin;
61cfdd57 624use lib "$FindBin::Bin/../lib";
625use [% name %];
fc7ec1d9 626
61cfdd57 627my $help = 0;
fc7ec1d9 628
61cfdd57 629GetOptions( 'help|?' => \$help );
fc7ec1d9 630
61cfdd57 631pod2usage(1) if ( $help || !$ARGV[0] );
fc7ec1d9 632
61cfdd57 633print [% name %]->run($ARGV[0])->content . "\n";
fc7ec1d9 634
6351;
fc7ec1d9 636
637=head1 NAME
638
639test - Catalyst Test
640
641=head1 SYNOPSIS
642
91864987 643test.pl [options] uri
fc7ec1d9 644
645 Options:
646 -help display this help and exits
647
648 Examples:
91864987 649 test.pl http://localhost/some_action
650 test.pl /some_action
fc7ec1d9 651
03a53815 652 See also:
653 perldoc Catalyst::Manual
654 perldoc Catalyst::Manual::Intro
655
fc7ec1d9 656=head1 DESCRIPTION
657
658Run a Catalyst action from the comand line.
659
660=head1 AUTHOR
661
61cfdd57 662Sebastian Riedel, C<sri@oook.de>
fc7ec1d9 663
664=head1 COPYRIGHT
665
666Copyright 2004 Sebastian Riedel. All rights reserved.
667
b160463f 668This library is free software. You can redistribute it and/or modify
669it under the same terms as perl itself.
fc7ec1d9 670
671=cut
fc7ec1d9 672
61cfdd57 673__create__
674[% startperl %] -w
fc7ec1d9 675
676use strict;
677use Getopt::Long;
678use Pod::Usage;
679use Catalyst::Helper;
680
61cfdd57 681my $help = 0;
fc7ec1d9 682
683GetOptions( 'help|?' => \$help );
684
61cfdd57 685pod2usage(1) if ( $help || !$ARGV[0] );
fc7ec1d9 686
61cfdd57 687my $helper = Catalyst::Helper->new;
688pod2usage(1) unless $helper->mk_component( '[% name %]', @ARGV );
fc7ec1d9 689
6901;
fc7ec1d9 691
692=head1 NAME
693
694create - Create a new Catalyst Component
695
696=head1 SYNOPSIS
697
91864987 698create.pl [options] model|view|controller name [helper] [options]
fc7ec1d9 699
700 Options:
701 -help display this help and exits
702
703 Examples:
91864987 704 create.pl controller My::Controller
705 create.pl view My::View
706 create.pl view MyView TT
707 create.pl view TT TT
708 create.pl model My::Model
709 create.pl model SomeDB CDBI dbi:SQLite:/tmp/my.db
710 create.pl model AnotherDB CDBI dbi:Pg:dbname=foo root 4321
b5524568 711 create.pl Ajax
03a53815 712
713 See also:
714 perldoc Catalyst::Manual
715 perldoc Catalyst::Manual::Intro
fc7ec1d9 716
717=head1 DESCRIPTION
718
719Create a new Catalyst Component.
720
721=head1 AUTHOR
722
723Sebastian Riedel, C<sri\@oook.de>
724
725=head1 COPYRIGHT
726
727Copyright 2004 Sebastian Riedel. All rights reserved.
728
b160463f 729This library is free software. You can redistribute it and/or modify
730it under the same terms as perl itself.
fc7ec1d9 731
732=cut
fc7ec1d9 733
61cfdd57 734__compclass__
735package [% class %];
736
737use strict;
738use base 'Catalyst::Base';
fc7ec1d9 739
61cfdd57 740[% IF type == 'C' %]
5a8ed4fe 741sub default : Private {
ffa15401 742 my ( $self, $c ) = @_;
61cfdd57 743 $c->res->output('Congratulations, [% class %] is on Catalyst!');
5a8ed4fe 744}
fc7ec1d9 745
61cfdd57 746[% END %]
fc7ec1d9 747=head1 NAME
748
61cfdd57 749[% class %] - A Component
fc7ec1d9 750
751=head1 SYNOPSIS
752
753 Very simple to use
754
755=head1 DESCRIPTION
756
757Very nice component.
758
759=head1 AUTHOR
760
ddb46924 761[%author%]
fc7ec1d9 762
763=head1 LICENSE
764
b160463f 765This library is free software . You can redistribute it and/or modify
766it under the same terms as perl itself.
fc7ec1d9 767
768=cut
769
7701;
fc7ec1d9 771
61cfdd57 772__comptest__
773[% IF type == 'C' %]
fc7ec1d9 774use Test::More tests => 3;
61cfdd57 775use_ok( Catalyst::Test, '[% app %]' );
776use_ok('[% class %]');
fc7ec1d9 777
61cfdd57 778ok( request('[% prefix %]')->is_success );
779[% ELSE %]
fc7ec1d9 780use Test::More tests => 1;
61cfdd57 781use_ok('[% class %]');
782[% END %]