use Test::Requires in tests
[gitmo/Moose.git] / t / 030_roles / 019_build.t
index fc4bb0e..faa5cbc 100644 (file)
@@ -1,7 +1,11 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 6;
+use Test::More;
+
+use Test::Requires {
+    'Test::Output' => '0.01', # skip all if not installed
+};
 
 # this test script ensures that my idiom of:
 # role: sub BUILD, after BUILD
@@ -22,12 +26,26 @@ do {
 do {
     package ClassWithBUILD;
     use Moose;
-    with 'TestRole';
+
+    ::stderr_is {
+        with 'TestRole';
+    } '';
 
     sub BUILD { push @CALLS, 'ClassWithBUILD::BUILD' }
 };
 
 do {
+    package ExplicitClassWithBUILD;
+    use Moose;
+
+    ::stderr_is {
+        with 'TestRole' => { -excludes => 'BUILD' };
+    } '';
+
+    sub BUILD { push @CALLS, 'ExplicitClassWithBUILD::BUILD' }
+};
+
+do {
     package ClassWithoutBUILD;
     use Moose;
     with 'TestRole';
@@ -59,3 +77,4 @@ do {
     }
 }
 
+done_testing;