[Jifty-commit] r6300 - in jifty/trunk: . lib/Jifty lib/Jifty/Plugin lib/Jifty/Plugin/TestServerWarnings lib/Jifty/Test/WWW lib/Jifty/View/Declare t/TestApp-Dispatcher/etc t/TestApp-Plugin-PasswordAuth/etc t/TestApp/t

Jifty commits jifty-commit at lists.jifty.org
Wed Feb 4 13:42:30 EST 2009


Author: alexmv
Date: Wed Feb  4 13:42:30 2009
New Revision: 6300

Added:
   jifty/trunk/lib/Jifty/Plugin/TestServerWarnings/
   jifty/trunk/lib/Jifty/Plugin/TestServerWarnings.pm
   jifty/trunk/lib/Jifty/Plugin/TestServerWarnings/Appender.pm
   jifty/trunk/lib/Jifty/Plugin/TestServerWarnings/View.pm
Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/Makefile.PL
   jifty/trunk/lib/Jifty/Logger.pm
   jifty/trunk/lib/Jifty/Server.pm
   jifty/trunk/lib/Jifty/Test.pm
   jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm
   jifty/trunk/lib/Jifty/View/Declare/Handler.pm
   jifty/trunk/t/TestApp-Dispatcher/etc/config.yml
   jifty/trunk/t/TestApp-Dispatcher/t/00-basic.t
   jifty/trunk/t/TestApp-Plugin-PasswordAuth/etc/config.yml
   jifty/trunk/t/TestApp/t/02-dispatch-show-rule-in-wrong-ruleset.t
   jifty/trunk/t/TestApp/t/07-sandboxing.t
   jifty/trunk/t/TestApp/t/20-error-pages.t
   jifty/trunk/t/TestApp/t/regex_meta_in_path_info.t
   jifty/trunk/t/TestApp/t/use_mason_wrapper.t

Log:
 r41792 at kohr-ah:  chmrr | 2009-02-04 13:41:24 -0500
 


Modified: jifty/trunk/Makefile.PL
==============================================================================
--- jifty/trunk/Makefile.PL	(original)
+++ jifty/trunk/Makefile.PL	Wed Feb  4 13:42:30 2009
@@ -73,7 +73,6 @@
 requires('SQL::ReservedWords');
 requires('Template::Declare' => '0.35');                # Template::Declare::Tags
 requires('Test::Base');
-requires('Test::Log4perl');
 requires('Test::LongString');
 requires('Test::More' => 0.62 ),
 requires('Test::Pod::Coverage'),

Modified: jifty/trunk/lib/Jifty/Logger.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Logger.pm	(original)
+++ jifty/trunk/lib/Jifty/Logger.pm	Wed Feb  4 13:42:30 2009
@@ -153,7 +153,6 @@
         my $log_level = uc Jifty->config->framework('LogLevel');
         my %default = (
             'log4perl.rootLogger'        => "$log_level,Screen",
-            '#log4perl.logger.SchemaTool' => "$log_level,Screen",
             'log4perl.appender.Screen'   => 'Log::Log4perl::Appender::Screen',
             'log4perl.appender.Screen.stderr' => 1,
             'log4perl.appender.Screen.layout' =>

Added: jifty/trunk/lib/Jifty/Plugin/TestServerWarnings.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/TestServerWarnings.pm	Wed Feb  4 13:42:30 2009
@@ -0,0 +1,101 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::TestServerWarnings;
+use base qw/Jifty::Plugin/;
+
+use LWP::Simple qw//;
+use Jifty::Plugin::TestServerWarnings::Appender;
+
+=head2 NAME
+
+Jifty::Plugin::TestServerWarnings - Stores server warnings away for later fetching
+
+=head2 DESCRIPTION
+
+This plugin removes the default "Screen" appender on the first request
+it sees, replacing it with a
+L<Jifty::Plugin::TestServerWarnings::Appender>, which stores away all
+messages it receives.  The warnings can be retrieved by a client-side
+process by calling L</decoded_warnings> with a base URI to the server.
+
+This plugin is automatically added for all jifty tests.
+
+=head2 METHODS
+
+=head3 new_request
+
+On the first call to new_request, the plugin adjusts the appenders.
+This causes it to only have effect if it is run in a forked server
+process, not in a test process.  If C<TEST_VERBOSE> is set, it does
+not remove the Screen appender.
+
+=cut
+
+sub new_request {
+    my $self = shift;
+    return if $self->{init}++;
+
+    my $root = Log::Log4perl->get_logger("");
+    $root->remove_appender("Screen") unless $ENV{TEST_VERBOSE};
+    my $a = Jifty::Plugin::TestServerWarnings::Appender->new(name => "TestServerAppender");
+    $root->add_appender($a);
+}
+
+=head3 add_warnings WARN, WARN, ..
+
+Takes the given warnings, and stores them away for later reporting.
+
+=cut
+
+sub add_warnings {
+    my $self = shift;
+    push @{ $self->{'stashed_warnings'} }, @_;
+}
+
+=head3 stashed_warnings
+
+Returns the stored warnings, as a list.  This does not clear the list,
+unlike L</encoded_warnings> or L</decoded_warnings>.
+
+=cut
+
+
+sub stashed_warnings {
+    my $self = shift;
+    return @{ $self->{'stashed_warnings'} || [] };
+}
+
+=head3 encoded_warnings
+
+Returns the stored warnings, encoded using L<Storable>.  This also
+clears the list of stashed warnings.
+
+=cut
+
+sub encoded_warnings {
+    my $self = shift;
+    my @warnings = splice @{ $self->{'stashed_warnings'} };
+
+    return Storable::nfreeze(\@warnings);
+}
+
+=head3 decoded_warnings URI
+
+Given the URI to a jifty server with this plugin enabled, retrieves
+and decodes the stored warnings, returning them.  This will also clear
+the server's stored list of warnings.
+
+=cut
+
+sub decoded_warnings {
+    my $self = shift;
+    my $base = shift;
+
+    my $uri = URI->new_abs( "/__jifty/test_warnings", $base );
+    my $text = LWP::Simple::get($uri);
+
+    return @{ Storable::thaw($text) };
+}
+
+1;

Added: jifty/trunk/lib/Jifty/Plugin/TestServerWarnings/Appender.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/TestServerWarnings/Appender.pm	Wed Feb  4 13:42:30 2009
@@ -0,0 +1,19 @@
+package Jifty::Plugin::TestServerWarnings::Appender;
+use strict;
+use warnings;
+use base qw/Log::Log4perl::Appender/;
+
+sub new {
+    my $class = shift;
+    return bless {@_}, $class;
+}
+
+sub log {
+    my $self = shift;
+    my $plugin = Jifty->find_plugin("Jifty::Plugin::TestServerWarnings");
+    my $message = $_[0]{message};
+    my @messages = ref $message eq "ARRAY" ? @{$message} : ($message);
+    $plugin->add_warnings(@messages);
+}
+
+1;

Added: jifty/trunk/lib/Jifty/Plugin/TestServerWarnings/View.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/TestServerWarnings/View.pm	Wed Feb  4 13:42:30 2009
@@ -0,0 +1,14 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::TestServerWarnings::View;
+use Jifty::View::Declare -base;
+
+template "/__jifty/test_warnings" => sub {
+    my $plugin = Jifty->find_plugin('Jifty::Plugin::TestServerWarnings');
+    Jifty->handler->apache->content_type("application/x-perl");
+    outs_raw($plugin->encoded_warnings);
+};
+
+1;
+

Modified: jifty/trunk/lib/Jifty/Server.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Server.pm	(original)
+++ jifty/trunk/lib/Jifty/Server.pm	Wed Feb  4 13:42:30 2009
@@ -42,9 +42,7 @@
     $self->setup_jifty(@_);
     $self->recording_on if $ENV{'JIFTY_RECORD'};
 
-
     return ($self);
-
 }
 
 =head2 setup_jifty
@@ -64,12 +62,10 @@
     $self->port( Jifty->config->framework('Web')->{'Port'} || 8888 );
 }
 
-=head2 handle_request
+=head2 handle_request CGI
 
-Overrives L<HTML::Server::Simple::Mason>'s handle_request method to
-make use of L<Module::Refresh> to refresh any relevant modules, as
-well as to set up the C<$JiftyWeb> global before handling the actual
-request.
+Calls L<Jifty::Handler/handle_request> with the CGI object.  If
+running tests, send test warnings on specific requests.
 
 =cut
 

Modified: jifty/trunk/lib/Jifty/Test.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Test.pm	(original)
+++ jifty/trunk/lib/Jifty/Test.pm	Wed Feb  4 13:42:30 2009
@@ -379,6 +379,9 @@
                 Port => ($$ % 5000) + 10000,
                 DataDir => File::Temp::tempdir('masonXXXXXXXXXX', CLEANUP => 1)
             },
+            Plugins => [
+                { TestServerWarnings => {} },
+            ],
             Mailer => 'Jifty::Test',
             MailerArgs => [],
             LogLevel => 'WARN',
@@ -435,7 +438,6 @@
     return $server;
 }
 
-
 =head2 web
 
 Like calling C<<Jifty->web>>.
@@ -601,6 +603,10 @@
 
 sub _ending {
     my $Test = Jifty::Test->builder;
+
+    my $plugin = Jifty->find_plugin("Jifty::Plugin::TestServerWarnings");
+    warn "Uncaught warning: $_" for $plugin->stashed_warnings;
+
     # Such a hack -- try to detect if this is a forked copy and don't
     # do cleanup in that case.
     return if $Test->{Original_Pid} != $$;

Modified: jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm	(original)
+++ jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm	Wed Feb  4 13:42:30 2009
@@ -6,6 +6,7 @@
 
 delete $ENV{'http_proxy'}; # Otherwise Test::WWW::Mechanize tries to go through your HTTP proxy
 
+use Test::More;
 use Jifty::YAML;
 use HTML::Lint;
 use Test::HTML::Lint qw();
@@ -432,7 +433,24 @@
         $Test::Builder::Level++;
         Test::HTML::Lint::html_ok( $lint, $self->content );
     }
-} 
+}
+
+sub warnings_like {
+    my $self = shift;
+    my @args = shift;
+    @args = @{$args[0]} if ref $args[0] eq "ARRAY";
+    my $reason = pop || "Server warnings matched";
+
+    local $Test::Builder::Level = $Test::Builder::Level;
+    $Test::Builder::Level++;
+
+    my $plugin = Jifty->find_plugin("Jifty::Plugin::TestServerWarnings");
+    my @warnings = $plugin->decoded_warnings($self->uri);
+    my $max = @warnings > @args ? $#warnings : $#args;
+    for (0 .. $max) {
+        like($warnings[$_], $_ <= $#args ? qr/$args[$_]/ : qr/(?!unexpected)unexpected warning/, $reason);
+    }
+}
 
 
 =head2 session

Modified: jifty/trunk/lib/Jifty/View/Declare/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/Handler.pm	(original)
+++ jifty/trunk/lib/Jifty/View/Declare/Handler.pm	Wed Feb  4 13:42:30 2009
@@ -6,6 +6,11 @@
 use base qw/Jifty::View Class::Accessor::Fast/;
 use Template::Declare;
 
+use Exception::Class ( 'Template::Declare::Exception' =>
+    {description => 'error in a Template::Declare template', alias => 'error'});
+ at Template::Declare::Exception::ISA = 'HTML::Mason::Exception';
+
+
 __PACKAGE__->mk_accessors(qw/root_class/);
 
 =head1 NAME
@@ -68,7 +73,12 @@
     my $template = shift;
 
     Template::Declare->buffer( Jifty->handler->buffer );
-    Template::Declare::Tags::show_page( $template, { %{Jifty->web->request->arguments}, %{Jifty->web->request->template_arguments || {}} } );
+    eval {
+        Template::Declare::Tags::show_page( $template, { %{Jifty->web->request->arguments}, %{Jifty->web->request->template_arguments || {}} } );
+    };
+    my $err = $@;
+    Template::Declare::Exception->throw($err) if $err;
+    
     return; # Explicit return so TD call above is in void context, and appends instead of returning.
 }
 

Modified: jifty/trunk/t/TestApp-Dispatcher/etc/config.yml
==============================================================================
--- jifty/trunk/t/TestApp-Dispatcher/etc/config.yml	(original)
+++ jifty/trunk/t/TestApp-Dispatcher/etc/config.yml	Wed Feb  4 13:42:30 2009
@@ -24,6 +24,7 @@
   Plugins: 
     - SkeletonApp: {}
     - CompressedCSSandJS: {}
+    - ErrorTemplates: {}
   PubSub: 
     Backend: Memcached
     Enable: ~

Modified: jifty/trunk/t/TestApp-Dispatcher/t/00-basic.t
==============================================================================
--- jifty/trunk/t/TestApp-Dispatcher/t/00-basic.t	(original)
+++ jifty/trunk/t/TestApp-Dispatcher/t/00-basic.t	Wed Feb  4 13:42:30 2009
@@ -2,7 +2,7 @@
 use warnings;
 use strict;
 
-use Jifty::Test::Dist tests => 8;
+use Jifty::Test::Dist tests => 9;
 use Jifty::Test::WWW::Mechanize;
 
 
@@ -33,3 +33,4 @@
 $mech->content_contains("woot");
 
 get_nok("/something_that_really_not_exists");
+$mech->warnings_like(qr/404/);

Modified: jifty/trunk/t/TestApp-Plugin-PasswordAuth/etc/config.yml
==============================================================================
--- jifty/trunk/t/TestApp-Plugin-PasswordAuth/etc/config.yml	(original)
+++ jifty/trunk/t/TestApp-Plugin-PasswordAuth/etc/config.yml	Wed Feb  4 13:42:30 2009
@@ -20,24 +20,12 @@
   Mailer: IO
   MailerArgs:
     - %log/mail.log%
-
   Plugins: 
     - Authentication::Password: {}
-    - 
-      REST: {}
-
-    - 
-      Halo: {}
-
-    - 
-      OnlineDocs: {}
-
-    - 
-      CompressedCSSandJS: {}
-
-    - 
-      AdminUI: {}
-
+    - REST: {}
+    - OnlineDocs: {}
+    - CompressedCSSandJS: {}
+    - AdminUI: {}
   PubSub: 
     Backend: Memcached
     Enable: ~
@@ -46,7 +34,6 @@
     BaseURL: http://localhost
     DataDir: var/mason
     Globals: []
-
     MasonConfig: 
       autoflush: 0
       default_escape_flags: h

Modified: jifty/trunk/t/TestApp/t/02-dispatch-show-rule-in-wrong-ruleset.t
==============================================================================
--- jifty/trunk/t/TestApp/t/02-dispatch-show-rule-in-wrong-ruleset.t	(original)
+++ jifty/trunk/t/TestApp/t/02-dispatch-show-rule-in-wrong-ruleset.t	Wed Feb  4 13:42:30 2009
@@ -2,9 +2,8 @@
 use warnings;
 use strict;
 
-use Jifty::Test::Dist tests => 7;
+use Jifty::Test::Dist tests => 11;
 use Jifty::Test::WWW::Mechanize;
-use Test::Log4perl;
 
 my $server  = Jifty::Test->make_server;
 
@@ -13,18 +12,17 @@
 my $URL     = $server->started_ok;
 my $mech    = Jifty::Test::WWW::Mechanize->new();
 
-{
-#    my $log = Test::Log4perl->expect(['', warn => qr/You can't call a 'show' rule in a 'before' or 'after' block in the dispatcher/ ]);
 $mech->get("$URL/before_stage_show");
 $mech->content_lacks("This is content");
 is( $mech->status , '404');
-}
+$mech->warnings_like([qr/can't call a 'show' rule in a 'before' or 'after' block/, qr/404/]);
+
 $mech->get("$URL/on_stage_show");
-#diag $mech->content;
 $mech->content_contains("his is content");
 
 $mech->get("$URL/after_stage_show");
 $mech->content_lacks("This is content");
 is( $mech->status , '404');
+$mech->warnings_like([qr/404/, qr/can't call a 'show' rule in a 'before' or 'after' block/]);
 
 1;

Modified: jifty/trunk/t/TestApp/t/07-sandboxing.t
==============================================================================
--- jifty/trunk/t/TestApp/t/07-sandboxing.t	(original)
+++ jifty/trunk/t/TestApp/t/07-sandboxing.t	Wed Feb  4 13:42:30 2009
@@ -2,7 +2,7 @@
 use warnings;
 use strict;
 
-use Jifty::Test::Dist tests => 79;
+use Jifty::Test::Dist tests => 98;
 use Jifty::Test::WWW::Mechanize;
 use Net::HTTP;
 use URI;
@@ -12,84 +12,104 @@
 isa_ok($server, 'Jifty::Server');
 
 my $uri = URI->new($server->started_ok);
+my $plugin = Jifty->find_plugin("Jifty::Plugin::TestServerWarnings");
 
 my ($status, $body);
 ($status, $body) = bogus_request("../../../../../../../../../etc/passwd");
 isnt($status, 200, "Didn't get a 200" );
 unlike( $body, qr/root/, "Doesn't have a root user in it");
+is(scalar $plugin->decoded_warnings($uri), 1);
 
 ($status, $body) = bogus_request("/../../../../../../../../../etc/passwd");
 isnt($status, 200, "Didn't get a 200" );
 unlike( $body, qr/root/, "Doesn't have a root user in it");
+is(scalar $plugin->decoded_warnings($uri), 1);
 
 ($status, $body) = bogus_request("/__jifty/../../../../../../../../../../etc/passwd");
 isnt($status, 200, "Didn't get a 200" );
 unlike( $body, qr/root/, "Doesn't have a root user in it");
+is(scalar $plugin->decoded_warnings($uri), 1);
 
 ($status, $body) = bogus_request("/static/../../../../../../../../../../etc/passwd");
 isnt($status, 200, "Didn't get a 200" );
 unlike( $body, qr/root/, "Doesn't have a root user in it");
+is(scalar $plugin->decoded_warnings($uri), 1);
 
 ($status, $body) = bogus_request("../templates/index.html");
 isnt( $status, 200, "Didn't get a 200" );
 unlike( $body, qr{\Q<&|/_elements/\E}, "Doesn't have the source code" );
+is(scalar $plugin->decoded_warnings($uri), 1);
 
 ($status, $body) = bogus_request("../templates/_elements/nav");
 isnt( $status, 200, "Didn't get a 200" );
 unlike( $body, qr/Jifty->web->navigation/, "Doesn't have the source" );
+is(scalar $plugin->decoded_warnings($uri), 1);
 
 ($status, $body) = bogus_request("/static/../templates/_elements/nav");
 isnt( $status, 200, "Didn't get a 200" );
 unlike( $body, qr/Jifty->web->navigation/, "Doesn't have the source" );
+is(scalar $plugin->decoded_warnings($uri), 1);
 
 ($status, $body) = bogus_request("/static/css/../../templates/index.html");
 isnt( $status, 200, "Didn't get a 200" );
 unlike( $body, qr/Jifty->web->navigation/, "Doesn't have the source" );
+is(scalar $plugin->decoded_warnings($uri), 1);
 
 ($status, $body) = bogus_request("/static/css/../../templates/_elements/nav");
 isnt( $status, 200, "Didn't get a 200" );
 unlike( $body, qr/Jifty->web->navigation/, "Doesn't have the source" );
+is(scalar $plugin->decoded_warnings($uri), 1);
 
 ($status, $body) = bogus_request("/static/css/base.css");
 is( $status, 200, "Got a 200" );
 like( $body, qr/body/, "Has content" );
+is(scalar $plugin->decoded_warnings($uri), 0);
 
 ($status, $body) = bogus_request("/static/css/../css/base.css");
 is( $status, 200, "Got a 200" );
 like( $body, qr/body/, "Has content" );
+is(scalar $plugin->decoded_warnings($uri), 0);
 
 ($status, $body) = bogus_request("/static/css//../css/base.css");
 is( $status, 200, "Got a 200" );
 like( $body, qr/body/, "Has content" );
+is(scalar $plugin->decoded_warnings($uri), 0);
 
 ($status, $body) = bogus_request("/somedir/stuff");
 is( $status, 200, "Got a 200" );
 like( $body, qr/dhandler arg is stuff/, "Has the content" );
+is(scalar $plugin->decoded_warnings($uri), 0);
 
 ($status, $body) = bogus_request("/somedir/stuff/../things");
 is( $status, 200, "Got a 200" );
 like( $body, qr/dhandler arg is things/, "Has the right content" );
+is(scalar $plugin->decoded_warnings($uri), 0);
 
 ($status, $body) = bogus_request("__jifty/webservices/yaml");
 is( $status, 200, "Got a 200" );
 like( $body, qr/--- {}/, "Got correct YAML response" );
+is(scalar $plugin->decoded_warnings($uri), 0);
 
 ($status, $body) = bogus_request("/__jifty//../__jifty/webservices/yaml");
 is( $status, 200, "Got a 200" );
 like( $body, qr/--- {}/, "Got correct YAML response" );
+is(scalar $plugin->decoded_warnings($uri), 0);
 
 ($status, $body) = bogus_request("/__jifty/webservices/../webservices/yaml");
 is( $status, 200, "Got a 200" );
 like( $body, qr/--- {}/, "Got correct YAML response" );
+is(scalar $plugin->decoded_warnings($uri), 0);
 
 ($status, $body) = bogus_request("///__jifty/webservices/yaml");
 is( $status, 200, "Got a 200" );
 like( $body, qr/--- {}/, "Got correct YAML response" );
+is(scalar $plugin->decoded_warnings($uri), 0);
 
 ($status, $body) = bogus_request("/__jifty/../index.html");
 is( $status, 200, "Got a 200" );
 unlike( $body, qr{\Q<&|/_elements/\E}, "Doesn't have the source code" );
 like( $body, qr/pony/, "Has the output" );
+is(scalar $plugin->decoded_warnings($uri), 0);
 
 sub bogus_request {
     my $url = shift;

Modified: jifty/trunk/t/TestApp/t/20-error-pages.t
==============================================================================
--- jifty/trunk/t/TestApp/t/20-error-pages.t	(original)
+++ jifty/trunk/t/TestApp/t/20-error-pages.t	Wed Feb  4 13:42:30 2009
@@ -9,24 +9,49 @@
 
 =cut
 
-use Jifty::Test::Dist tests => 10;
+use Jifty::Test::Dist tests => 1 + 2 * 29;
 use Jifty::Test::WWW::Mechanize;
 
-ok(1, "Loaded the test script");
-
-my $server = Jifty::Test->make_server;
-isa_ok( $server, 'Jifty::Server' );
-my $URL = $server->started_ok;
-
+my $URL = Jifty::Test->make_server->started_ok;
 my $mech = Jifty::Test::WWW::Mechanize->new;
-$mech->get_ok("$URL/template-with-error");
-$mech->base_like(qr/mason_internal_error/);
-$mech->content_like(qr/locate object method .*?non_existant_method.*?/);
-$mech->content_like(qr/template-with-error line 5/);
-
-ok($mech->continuation, "Have a continuation");
-ok($mech->continuation->response->error, "Have an error set");
-isa_ok($mech->continuation->response->error, "HTML::Mason::Exception", "Error is a reference");
+
+for my $path ("", "/td") {
+    my $prefix = "$URL$path";
+    $mech->get_ok("$prefix/template-with-error");
+#    $mech->warnings_like(qr/Can't locate object method "non_existent_method" via package "Jifty::Web"/);
+    $mech->base_like(qr{errors/500}, "End up on error page");
+    $mech->content_like(qr/something went awry/i, "Have error header");
+    $mech->content_like(qr/locate object method .*?non_existent_method.*?/, "Have error itself, if in devel mode");
+    $mech->content_like(qr/template-with-error/, "Have stack trace");
+    $mech->content_unlike(qr/Before error/, "Don't have content from before error");
+    $mech->content_unlike(qr/After error/, "Don't have content from after error");
+
+    ok($mech->continuation, "Have a continuation");
+    ok($mech->continuation->response->error, "Have an error set");
+    isa_ok($mech->continuation->response->error, "HTML::Mason::Exception", "Error is a reference");
+
+    # Region itself gets full page wrapper if it's the only request
+    $mech->get_ok("$prefix/region-with-error", "Request region (no wrapper!) with error");
+#    $mech->warnings_like(qr/Can't locate object method "non_existent_method" via package "Jifty::Web"/);
+    $mech->base_like(qr{errors/500}, "End up at error page");
+    $mech->content_like(qr/something went awry/i, "Have error header");
+    $mech->content_like(qr/locate object method .*?non_existent_method.*?/, "Have error itself, if in devel mode");
+    $mech->content_like(qr/region-with-error/, "Have stack trace");
+    $mech->content_unlike(qr/Region before/, "Don't have content from before error");
+    $mech->content_unlike(qr/Region after/, "Don't have content from after error");
+
+    # If it's a subrequest, don't nest wrappers
+    $mech->get_ok("$prefix/call-region-with-error");
+#    $mech->warnings_like(qr/Can't locate object method "non_existent_method" via package "Jifty::Web"/);
+    $mech->base_unlike(qr{errors/500}, "Doesn't redirect if only a region error");
+    $mech->content_unlike(qr/something went awry/i, "Doesn't have error header");
+    $mech->content_like(qr/locate object method .*?non_existent_method.*?/, "Has error itself, if in devel mode");
+    $mech->content_like(qr/region-with-error/, "Have stack trace");
+    $mech->content_like(qr/Calling before/, "Does have region content from before error");
+    $mech->content_like(qr/Region before/, "Does have calling content from before error"); # TODO: change?
+    $mech->content_unlike(qr/Region after/, "Don't have region content from after error");
+    $mech->content_like(qr/Calling after/, "Does have calling content from after error");
+}
 
 1;
 

Modified: jifty/trunk/t/TestApp/t/regex_meta_in_path_info.t
==============================================================================
--- jifty/trunk/t/TestApp/t/regex_meta_in_path_info.t	(original)
+++ jifty/trunk/t/TestApp/t/regex_meta_in_path_info.t	Wed Feb  4 13:42:30 2009
@@ -6,7 +6,7 @@
 use warnings;
 use strict;
 
-use Jifty::Test::Dist tests => 2;
+use Jifty::Test::Dist tests => 3;
 use Jifty::Test::WWW::Mechanize;
 
 my $server  = Jifty::Test->make_server;
@@ -15,4 +15,4 @@
 
 $mech->get("$URL/*****");
 is( $mech->status, '404', 'regex metachars in URL does not cause error' );
-
+$mech->warnings_like(qr/404/);

Modified: jifty/trunk/t/TestApp/t/use_mason_wrapper.t
==============================================================================
--- jifty/trunk/t/TestApp/t/use_mason_wrapper.t	(original)
+++ jifty/trunk/t/TestApp/t/use_mason_wrapper.t	Wed Feb  4 13:42:30 2009
@@ -2,7 +2,7 @@
 use warnings;
 use strict;
 
-use Jifty::Test::Dist tests => 6;
+use Jifty::Test::Dist tests => 7;
 use Jifty::Test::WWW::Mechanize;
 
 my $server = Jifty::Test->make_server;
@@ -16,3 +16,4 @@
 
 $mech->get_ok( $url . '/_elements/wrapper', 'getting the wrapper directly');
 $mech->content_contains( 'Something went awry', 'and we were not able to');
+$mech->warnings_like(qr/Unhandled web error/);


More information about the Jifty-commit mailing list