Added path_to method
[catagits/Catalyst-Runtime.git] / t / unit / core / path_to.t
diff --git a/t/unit/core/path_to.t b/t/unit/core/path_to.t
new file mode 100644 (file)
index 0000000..a21d7f9
--- /dev/null
@@ -0,0 +1,33 @@
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+use Test::MockObject;
+
+my %non_unix = (
+    MacOS   => 1,
+    MSWin32 => 1,
+    os2     => 1,
+    VMS     => 1,
+    epoc    => 1,
+    NetWare => 1,
+    dos     => 1,
+    cygwin  => 1
+);
+
+my $os = $non_unix{$^O} ? $^O : 'Unix';
+
+plan skip_all => 'tests require Unix' unless $os eq 'Unix';
+
+my $context = Test::MockObject->new;
+
+use_ok('Catalyst');
+
+$context->mock( 'config', sub { { home => '/home/sri/my-app/' } } );
+
+is( Catalyst::path_to( $context, 'foo' ), '/home/sri/my-app/foo', 'Unix path' );
+
+$context->mock( 'config', sub { { home => '/Users/sri/myapp' } } );
+
+is( Catalyst::path_to( $context, 'foo', 'bar' ),
+    '/Users/sri/myapp/foo/bar', 'deep Unix path' );