f4fe89f5ff662bb1a89bd8d12f2cb21f746d813c
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_path_to.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use FindBin;
6 use Path::Class;
7 use File::Basename;
8
9 my %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
20 my $os = $non_unix{$^O} ? $^O : 'Unix';
21
22 if ( $os ne 'Unix' ) {
23     plan skip_all => 'tests require Unix';
24 }
25
26 use_ok('Catalyst');
27
28 my $context = 'Catalyst';
29
30 $context->setup_home;
31 my $base = dir($FindBin::Bin)->relative->stringify;
32
33 isa_ok( Catalyst::path_to( $context, $base ), 'Path::Class::Dir' );
34 isa_ok( Catalyst::path_to( $context, $base, basename $0 ), 'Path::Class::File' );
35
36 my $config = Catalyst->config;
37
38 $config->{home} = '/home/sri/my-app/';
39
40 is( Catalyst::path_to( $context, 'foo' ), '/home/sri/my-app/foo', 'Unix path' );
41
42 $config->{home} = '/Users/sri/myapp/';
43
44 is( Catalyst::path_to( $context, 'foo', 'bar' ),
45     '/Users/sri/myapp/foo/bar', 'deep Unix path' );
46
47 done_testing;