Make sure path_to returns an instance of the right Path::Class class.
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_path_to.t
CommitLineData
01033d73 1use strict;
2use warnings;
3
5b19d407 4use Test::More;
0891873b 5use FindBin;
6use Path::Class;
7use File::Basename;
01033d73 8
9my %non_unix = (
10 MacOS => 1,
11 MSWin32 => 1,
12 os2 => 1,
13 VMS => 1,
14 epoc => 1,
15 NetWare => 1,
16 dos => 1,
17 cygwin => 1
18);
19
20my $os = $non_unix{$^O} ? $^O : 'Unix';
21
0891873b 22if ( $os ne 'Unix' ) {
c7ded7aa 23 plan skip_all => 'tests require Unix';
5b19d407 24}
01033d73 25
01033d73 26use_ok('Catalyst');
27
fa32ac82 28my $context = 'Catalyst';
29
0891873b 30$context->setup_home;
31my $base = dir($FindBin::Bin)->relative->stringify;
32
33isa_ok( Catalyst::path_to( $context, $base ), 'Path::Class::Dir' );
34isa_ok( Catalyst::path_to( $context, $base, basename $0 ), 'Path::Class::File' );
35
fa32ac82 36my $config = Catalyst->config;
37
38$config->{home} = '/home/sri/my-app/';
01033d73 39
40is( Catalyst::path_to( $context, 'foo' ), '/home/sri/my-app/foo', 'Unix path' );
41
fa32ac82 42$config->{home} = '/Users/sri/myapp/';
01033d73 43
44is( Catalyst::path_to( $context, 'foo', 'bar' ),
45 '/Users/sri/myapp/foo/bar', 'deep Unix path' );
0891873b 46
47done_testing;