Test::TempDir
[gitmo/MooseX-Storage.git] / t / 105_io_atomic_w_utf8.t
index 8c19f5d..d831409 100644 (file)
@@ -4,10 +4,15 @@ use strict;
 use warnings;
 
 use Test::More;
+use Test::TempDir;
+use File::Spec::Functions;
+my $dir = tempdir;
 
 BEGIN {  
     eval "use IO::AtomicFile";
-    plan skip_all => "IO::AtomicFile is required for this test" if $@;            
+    plan skip_all => "IO::AtomicFile is required for this test" if $@;        
+    eval "use JSON::Any";
+    plan skip_all => "JSON::Any is required for this test" if $@;        
     # NOTE: 
     # this is because JSON::XS is 
     # the only one which really gets
@@ -37,7 +42,7 @@ use utf8;
     );
 }
 
-my $file = 'temp.json';
+my $file = catfile($dir, 'temp.json');
 
 {
     my $foo = Foo->new;
@@ -79,4 +84,3 @@ unlink $file;
       '... got the string we expected');
 }
 
-unlink $file;