throw error on failed new in run_if_script
[catagits/Web-Simple.git] / t / run_if_script.t
index ede9d89..dc66514 100644 (file)
@@ -1,6 +1,7 @@
 use strictures;
 
 use Test::More;
+use Test::Fatal 'exception';
 
 {
     use Web::Simple 'RunTest';
@@ -12,6 +13,14 @@ use Test::More;
     sub run              { @_, "run" }
 }
 
+{
+    use Web::Simple 'DieTest';
+
+    package DieTest;
+    use Moo;
+    has die => is => ro => required => 1;
+}
+
 is(
     sub { RunTest->run_if_script }
       ->(),
@@ -39,4 +48,10 @@ is_deeply(
     "passing arguments to run_if_script has them passed on to the run method"
 );
 
+like(
+    exception { DieTest->_build_for_run_if_script },    #
+    qr/^Failed to create new 'DieTest' object during/,
+    "object creation in run_if_script decorates failure with useful information"
+);
+
 done_testing;