add (author-only) warning tests
[gitmo/MooseX-Types-Common.git] / t / 03-idiot.t
index 33b0939..9d270c7 100644 (file)
@@ -2,27 +2,25 @@ use strict;
 use warnings FATAL => 'all';
 
 use Test::More;
+use Test::Warnings ':no_end_test', ':all';
+use Test::Deep;
 
 # Test for a warning when you make the stupid mistake I make all the time
 # of saying use MooseX::Types::Common qw/NonEmptySimpleStr/;
 
-BEGIN {
-    eval { require Capture::Tiny }
-        or plan skip_all => 'Capture::Tiny needed for these tests';
-}
+require MooseX::Types::Common;
 
-plan tests => 4;
+cmp_deeply(
+    [ warnings { MooseX::Types::Common->import } ],
+    [],
+    'No warning if nothing imported',
+);
 
-use_ok 'MooseX::Types::Common';
-
-my ($stdout, $stderr) = Capture::Tiny::capture(sub {
-    MooseX::Types::Common->import;
-});
-is $stderr, '', 'No warning if nothing imported';
-
-($stdout, $stderr) = Capture::Tiny::capture(sub {
-    MooseX::Types::Common->import('NonEmptySimpleStr');
-});
-like $stderr, qr/Did you mean/, 'Got warning';
-like $stderr, qr/NonEmptySimpleStr/, 'Warning mentions bad type';
+cmp_deeply(
+    [ warnings { MooseX::Types::Common->import('NonEmptySimpleStr') } ],
+    [ re(qr/Did you mean.*NonEmptySimpleStr/s) ],
+    'Warning mentions bad type',
+);
 
+had_no_warnings if $ENV{AUTHOR_TESTING};
+done_testing;