use Test::Requires in tests
[gitmo/Moose.git] / t / 030_roles / 019_build.t
index 3e65149..faa5cbc 100644 (file)
@@ -1,8 +1,11 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 10;
-use Test::Output;
+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
@@ -24,9 +27,9 @@ do {
     package ClassWithBUILD;
     use Moose;
 
-    ::stderr_like {
+    ::stderr_is {
         with 'TestRole';
-    } qr/The ClassWithBUILD class has implicitly overridden the method \(BUILD\) from role TestRole\./;
+    } '';
 
     sub BUILD { push @CALLS, 'ClassWithBUILD::BUILD' }
 };
@@ -36,7 +39,7 @@ do {
     use Moose;
 
     ::stderr_is {
-        with 'TestRole' => { excludes => 'BUILD' };
+        with 'TestRole' => { -excludes => 'BUILD' };
     } '';
 
     sub BUILD { push @CALLS, 'ExplicitClassWithBUILD::BUILD' }
@@ -59,14 +62,6 @@ do {
         'TestRole::BUILD:after',
     ]);
 
-    ExplicitClassWithBUILD->new;
-
-    is_deeply([splice @CALLS], [
-        'TestRole::BUILD:before',
-        'ExplicitClassWithBUILD::BUILD',
-        'TestRole::BUILD:after',
-    ]);
-
     ClassWithoutBUILD->new;
 
     is_deeply([splice @CALLS], [
@@ -77,9 +72,9 @@ do {
 
     if (ClassWithBUILD->meta->is_mutable) {
         ClassWithBUILD->meta->make_immutable;
-        ExplicitClassWithBUILD->meta->make_immutable;
         ClassWithoutBUILD->meta->make_immutable;
         redo;
     }
 }
 
+done_testing;