[Rt-commit] r15914 - in rt/3.8/trunk: lib/RT/Test
sartak at bestpractical.com
sartak at bestpractical.com
Thu Sep 11 04:54:27 EDT 2008
Author: sartak
Date: Thu Sep 11 04:54:27 2008
New Revision: 15914
Modified:
rt/3.8/trunk/ (props changed)
rt/3.8/trunk/lib/RT/Test/Web.pm
Log:
r71646 at onn: sartak | 2008-09-11 04:52:13 -0400
warning_like method for testing that there was only one warning, and it matches a particular regex
Modified: rt/3.8/trunk/lib/RT/Test/Web.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Test/Web.pm (original)
+++ rt/3.8/trunk/lib/RT/Test/Web.pm Thu Sep 11 04:54:27 2008
@@ -150,4 +150,26 @@
return @warnings;
}
+sub warning_like {
+ my $self = shift;
+ my $re = shift;
+ my $name = shift;
+
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ my @warnings = $self->get_warnings;
+ if (@warnings == 0) {
+ Test::More::fail("no warnings emitted; expected 1");
+ }
+ elsif (@warnings > 1) {
+ Test::More::fail(scalar(@warnings) . " warnings emitted; expected 1");
+ for (@warnings) {
+ Test::More::diag("got warning: $_");
+ }
+ }
+ else {
+ Test::More::like($warnings[0], $re, $name);
+ }
+}
+
1;
More information about the Rt-commit
mailing list