[Jifty-commit] r6628 - in jifty/trunk: t/TestApp-Plugin-REST/t

Jifty commits jifty-commit at lists.jifty.org
Tue Mar 17 13:18:11 EDT 2009


Author: sartak
Date: Tue Mar 17 13:18:11 2009
New Revision: 6628

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/t/TestApp-Plugin-REST/t/03-format.t

Log:
 r81291 at onn:  sartak | 2009-03-17 13:17:11 -0400
 Handle redirection and thawing errors in result_of


Modified: jifty/trunk/t/TestApp-Plugin-REST/t/03-format.t
==============================================================================
--- jifty/trunk/t/TestApp-Plugin-REST/t/03-format.t	(original)
+++ jifty/trunk/t/TestApp-Plugin-REST/t/03-format.t	Tue Mar 17 13:18:11 2009
@@ -45,13 +45,25 @@
         my $url = $URL . $request->{url} . '.' . $format;
 
         my $method = $request->{mech_method};
-        $mech->$method($url, @{ $request->{mech_args} || [] });
+        my $response = $mech->$method($url, @{ $request->{mech_args} || [] });
 
-        is($mech->status, 200, "HTTP response status for $url");
+        ok($response->is_success, "$method successful");
+        my @contents = $response->content;
+
+        if (my $location = $response->header('Location')) {
+            $response = $mech->get($location);
+            ok($response->is_success, "redirect successful");
+            push @contents, $response->content;
+        }
 
-        my $loaded = $loaders{$format}->($mech->content);
         local $Test::Builder::Level = $Test::Builder::Level + 1;
-        $test->($loaded);
+
+        eval {
+            @contents = map { scalar $loaders{$format}->($_) } @contents;
+        };
+        fail($@) if $@;
+
+        $test->(@contents);
     }
 }
 


More information about the Jifty-commit mailing list