File: helper.t

package info (click to toggle)
libcatalyst-view-mason-perl 0.19-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 372 kB
  • sloc: perl: 2,028; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,200 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!perl

use strict;
use warnings;
use Cwd;
use File::Path;
use File::Spec::Functions qw/catdir catfile/;
use Test::More;

eval 'use Test::File';
plan skip_all => 'Test::File required' if $@;

eval 'use Test::Exception';
plan skip_all => 'Test::Exception required' if $@;

eval 'use Catalyst::Helper';
plan skip_all => 'Catalyst::Helper required' if $@;

plan tests => 4;

my $app_name = 'TestApp';
my $old_cwd  = cwd();
my $test_dir = catdir(qw/t var/);

if (!-d $test_dir) {
    mkdir $test_dir or BAIL_OUT("Failed to create test directory: $!");
}
chdir $test_dir;

my $helper = Catalyst::Helper->new;

$helper->mk_app($app_name);
$FindBin::Bin = $FindBin::Bin = catdir($app_name, 'lib');

$helper->mk_component($app_name, 'view', 'Mason', 'Mason');

my $module = catfile($app_name, 'lib', $app_name, 'View', 'Mason.pm');
file_exists_ok($module, 'module created');

lives_ok(sub {
        do $module;
}, 'module compiles fine');

ok(!TestApp::View::Mason->config->{use_match}, 'module sets use_match to false');
ok(TestApp::View::Mason->isa('Catalyst::View::Mason'), 'module inherits from C::V::Mason');

END {
    if (defined $old_cwd) {
        chdir $old_cwd;
        rmtree($test_dir);
    }
}