eval require instead of use
[gitmo/MooseX-Storage.git] / t / 104_io_w_utf8.t
index 39753ad..6cc5ec5 100644 (file)
@@ -4,8 +4,13 @@ use strict;
 use warnings;
 
 use Test::More;
+use File::Temp qw(tempdir);
+use File::Spec::Functions;
+my $dir = tempdir( CLEANUP => 1 );
 
 BEGIN {  
+    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
@@ -35,7 +40,7 @@ use utf8;
     );
 }
 
-my $file = 'temp.json';
+my $file = catfile($dir,'temp.json');
 
 {
     my $foo = Foo->new;
@@ -77,4 +82,3 @@ unlink $file;
       '... got the string we expected');
 }
 
-unlink $file;