[Jifty-commit] r1353 - in jifty/trunk: lib/Jifty/Test/WWW

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Jun 22 16:21:03 EDT 2006


Author: alexmv
Date: Thu Jun 22 16:21:03 2006
New Revision: 1353

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm

Log:
 r14217 at zoq-fot-pik:  chmrr | 2006-06-22 16:20:32 -0400
  * Test helper to request a fragment


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	Thu Jun 22 16:21:03 2006
@@ -205,6 +205,44 @@
     return $content;
 }
 
+=head2 request_fragment PATH ARGUMENT => VALUE, [ ... ]
+
+Makes a request for the fragment at PATH, using the webservices API,
+and returns the string of the result.
+
+=cut
+
+sub fragment_request {
+    my $self = shift;
+    my $path = shift;
+    my %args = @_;
+
+    my $uri = $self->uri->clone;
+    $uri->path("__jifty/webservices/xml");
+
+    my $request = HTTP::Request->new(
+        POST => $uri,
+        [ 'Content-Type' => 'text/x-yaml' ],
+        Jifty::YAML::Dump(
+            {   path => $uri->path,
+                fragments => {
+                    fragment => {
+                        name  => 'fragment',
+                        path  => $path,
+                        args  => \%args
+                    }
+                }
+            }
+        )
+    );
+    my $result = $self->request( $request );
+    use XML::Simple;
+    my $content = eval { XML::Simple::XMLin($result->content, SuppressEmpty => '')->{fragment}{content} } || '';
+    $self->back;
+    return $content;
+}
+
+
 # When it sees something like
 # http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd as a DOCTYPE, this will make
 # it open static/dtd/xhtml1-strict.dtd instead -- great for offline hacking!


More information about the Jifty-commit mailing list