[Bps-public-commit] Plack-Middleware-Test-StashWarnings branch, master, updated. 87781722730251fb0a1316b6e8ac51d8421f1801

Shawn Moore sartak at bestpractical.com
Wed Jun 8 16:53:58 EDT 2011


The branch, master has been updated
       via  87781722730251fb0a1316b6e8ac51d8421f1801 (commit)
       via  3a3942777098875f33386fd4f1b0b86be17aaafa (commit)
      from  435d26feb25676ca2eea1316226bdcfb7548479e (commit)

Summary of changes:
 Changes                                    |    4 +++
 README                                     |   39 +++++++++++++++++++++++++--
 lib/Plack/Middleware/Test/StashWarnings.pm |    2 +-
 3 files changed, 41 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit 3a3942777098875f33386fd4f1b0b86be17aaafa
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Jun 8 16:53:24 2011 -0400

    Regenerate README

diff --git a/README b/README
index a192c52..be17797 100644
--- a/README
+++ b/README
@@ -3,19 +3,52 @@ NAME
     warnings
 
 SYNOPSIS
+      # for your PSGI application:
       enable "Test::StashWarnings";
 
 
+      # for your Test::WWW::Mechanize subclass:
       use Storable 'thaw';
-      $mech->get('/__test_warnings');
-      my @warnings = @{ thaw($mech->content) };
-      like(@warnings[0], qr/No private key/);
+      sub get_warnings {
+          local $Test::Builder::Level = $Test::Builder::Level + 1;
+          my $self = shift;
+  
+          my $clone = $self->clone;
+          return unless $clone->get_ok('/__test_warnings');
+  
+          my @warnings = @{ thaw $clone->content };
+          return @warnings;
+      }
 
 DESCRIPTION
     Plack::Middleware::Test::StashWarnings is a Plack middleware component
     to record warnings generated by your application so that you can test
     them to make sure your application complains about the right things.
 
+    The warnings generated by your application are available at a special
+    URL ("/__test_warnings"), encoded with "nfreeze" in Storable. So using
+    Test::WWW::Mechanize you can just "get" that URL and "thaw" in Storable
+    its content.
+
+RATIONALE
+    Warnings are an important part of any application. Your web application
+    should warn its operators when something is amiss.
+
+    Almost as importantly, your web application should gracefully cope with
+    bad input, the back button, and all other aspects of the user
+    experience.
+
+    Unfortunately, tests seldom cover what happens when things go poorly.
+    Are you *sure* that your application correctly denies that action and
+    logs the failure? Are you *sure* it will tomorrow?
+
+    This module lets you retrieve the warnings that your forked server
+    issues. That way you can test that your application continues to issue
+    warnings when it makes sense. Catching the warnings also keeps your test
+    output tidy. Finally, you'll be able to see (and be notified via failing
+    tests) when your application issues new, unexpected warnings so you can
+    fix them immediately.
+
 AUTHOR
     Shawn M Moore "sartak at bestpractical.com"
 

commit 87781722730251fb0a1316b6e8ac51d8421f1801
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Jun 8 16:51:06 2011 -0400

    0.05 and its Changes

diff --git a/Changes b/Changes
index 873983d..48ec7e7 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Perl extension Plack::Middleware::Test::StashWarnings
 
+0.05  2011-06-08
+        - improved documentation
+        - try harder to use $SIG{__WARN__} if it's there
+
 0.04  2010-11-17
         - add implied dep on Scalar::Util
 
diff --git a/lib/Plack/Middleware/Test/StashWarnings.pm b/lib/Plack/Middleware/Test/StashWarnings.pm
index 5139504..65d61b2 100644
--- a/lib/Plack/Middleware/Test/StashWarnings.pm
+++ b/lib/Plack/Middleware/Test/StashWarnings.pm
@@ -2,7 +2,7 @@ package Plack::Middleware::Test::StashWarnings;
 
 use strict;
 use 5.008_001;
-our $VERSION = '0.04';
+our $VERSION = '0.05';
 
 use parent qw(Plack::Middleware);
 use Carp ();

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list