Anonymous avatar Anonymous committed 280c1b5

Fix form_submit_ok.

Comments (0)

Files changed (4)

Test-WWW-Mechanize-Mojo/CHANGES

 Revision history for Perl module Test::WWW::Mechanize::Mojo :
 
+v0.0.3      Thu Mar  4 00:35:10 IST 2010
+    - Fix submit_form_ok on the contemporary Mojo::Client . (with a test).
+
 v0.0.2      Tue Mar  2 23:27:43 IST 2010
     - Add a missing empty line before an "=end". Without it, the POD
     was not displayed properly by perldoc and by http://search.cpan.org/ .

Test-WWW-Mechanize-Mojo/MANIFEST

 README
 t/auth-test.t
 t/cookies.t
+t/form_submit.t
 t/lib/Catty.pm
 t/lib/CattySession.pm
 t/lib/ExternalCatty.pm

Test-WWW-Mechanize-Mojo/lib/Test/WWW/Mechanize/Mojo.pm

 
     my $method = lc($request->method());
 
-    $client->$method($uri->opaque(), 
-        +{ (map { $_ => $request->header($_) } 
-                $request->header_field_names()
-            ) 
-        },
+    my %headers =
+    (
+        map { $_ => $request->header($_) } 
+        $request->header_field_names()
+    );
+
+    $client->$method($uri->path(), 
+        # TODO : fix this to pass it as a ref.
+        %headers,
         $request->content,
         sub { my (undef, $tx, $redirs) = @_; 
             $t->tx($tx) and $t->redirects($redirs) 

Test-WWW-Mechanize-Mojo/t/form_submit.t

+#!perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 5;
+
+use Test::Mojo;
+use Test::WWW::Mechanize::Mojo;
+
+require "t/lib/mojjy.pl";
+
+use Encode qw();
+use Test::WWW::Mechanize::Mojo;
+
+my $root = "http://localhost";
+
+my $t = Test::Mojo->new();
+my $m = Test::WWW::Mechanize::Mojo->new( autocheck => 0, tester => $t,);
+
+# TEST
+$m->get_ok("$root/form");
+# TEST
+is( $m->ct, "text/html" );
+# TEST
+$m->title_is("Form test");
+
+my $email = "sophie\@hello.tld";
+
+# $t->post_ok("/form-submit",
+#    { 'Content-Type' => 'application/x-www-form-urlencoded'} , 
+#    'email=shlomif'
+# );
+
+$m->submit_form_ok(
+    {
+        form_id => "register",
+        fields =>
+        {
+            email => $email,
+        },
+    },
+    "Was able to submit form.",
+);
+
+# TEST
+$m->content_like(
+    qr{Your email is \Q$email\E}
+);
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.