Change path_to testing to use a real app to test it really works
Tomas Doran [Mon, 6 Feb 2012 22:17:30 +0000 (22:17 +0000)]
t/aggregate/unit_core_path_to.t

index 823e626..b93faa8 100644 (file)
@@ -5,6 +5,11 @@ use Test::More;
 use FindBin;
 use Path::Class;
 use File::Basename;
+BEGIN {
+    delete $ENV{CATALYST_HOME}; # otherwise it'll set itself up to the wrong place
+}
+use lib "$FindBin::Bin/../lib";
+use TestApp;
 
 my %non_unix = (
     MacOS   => 1,
@@ -25,25 +30,16 @@ if ( $os ne 'Unix' ) {
 
 use_ok('Catalyst');
 
-my $context = 'Catalyst';
-
-delete $ENV{CATALYST_HOME}; # otherwise it'll set itself up to the wrong place
-
-$context->setup_home;
-my $base = dir($FindBin::Bin)->relative->stringify;
+my $context = 'TestApp';
+my $base;
 
-isa_ok( Catalyst::path_to( $context, $base ), 'Path::Class::Dir' );
-isa_ok( Catalyst::path_to( $context, $base, basename $0 ), 'Path::Class::File' );
+isa_ok( $base = Catalyst::path_to( $context, '' ), 'Path::Class::Dir' );
 
 my $config = Catalyst->config;
 
-$config->{home} = '/home/sri/my-app/';
-
-is( Catalyst::path_to( $context, 'foo' ), '/home/sri/my-app/foo', 'Unix path' );
-
-$config->{home} = '/Users/sri/myapp/';
+is( Catalyst::path_to( $context, 'foo' ), "$base/foo", 'Unix path' );
 
 is( Catalyst::path_to( $context, 'foo', 'bar' ),
-    '/Users/sri/myapp/foo/bar', 'deep Unix path' );
+    "$base/foo/bar", 'deep Unix path' );
 
 done_testing;