Commit | Line | Data |
2f381252 |
1 | use Test::More tests => 8; |
059c085b |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | # simulates an entire testapp rooted at t/something |
7 | # except without bothering creating it since its |
8 | # only the -e check on the Makefile.PL that matters |
9 | |
10 | BEGIN { use_ok 'Catalyst::Utils' } |
11 | use FindBin; |
2f381252 |
12 | use Path::Class::Dir; |
059c085b |
13 | |
2f381252 |
14 | { |
15 | $INC{'TestApp.pm'} = "$FindBin::Bin/something/script/foo/../../lib/TestApp.pm"; |
16 | my $home = Catalyst::Utils::home('TestApp'); |
17 | like($home, qr{t[\/\\]something}, "has path TestApp/t/something"); |
18 | unlike($home, qr{[\/\\]script[\/\\]foo}, "doesn't have path /script/foo"); |
19 | } |
059c085b |
20 | |
2f381252 |
21 | { |
22 | $INC{'TestApp.pm'} = "$FindBin::Bin/something/script/foo/bar/../../../lib/TestApp.pm"; |
23 | my $home = Catalyst::Utils::home('TestApp'); |
24 | like($home, qr{t[\/\\]something}, "has path TestApp/t/something"); |
25 | unlike($home, qr{[\/\\]script[\/\\]foo[\/\\]bar}, "doesn't have path /script/foo/bar"); |
26 | } |
059c085b |
27 | |
2f381252 |
28 | { |
29 | $INC{'TestApp.pm'} = "$FindBin::Bin/something/script/../lib/TestApp.pm"; |
30 | my $home = Catalyst::Utils::home('TestApp'); |
31 | like($home, qr{t[\/\\]something}, "has path TestApp/t/something"); |
32 | unlike($home, qr{[\/\\]script[\/\\]foo}, "doesn't have path /script/foo"); |
33 | } |
34 | |
35 | { |
36 | $INC{'TestApp.pm'} = "TestApp.pm"; |
37 | my $dir = "$FindBin::Bin/something"; |
38 | chdir( $dir ); |
39 | |
40 | my $home = Catalyst::Utils::home('TestApp'); |
41 | |
42 | $dir = Path::Class::Dir->new( $dir ); |
43 | is( $home, "$dir", 'same dir loading' ); |
44 | } |