dear M users / stefan : still stuck.  this probably has a simple answer. 
 here is my attempt at a simple form page and a test:

#!/usr/bin/env perl
use Test::More;
use Test::Mojo;

my $t = Test::Mojo->new;
$t->get_ok('http://localhost:3000/')->status_is(200)->content_like(qr{<h1>
TITLE: basic mojolicious cribsheet</h1>});
$t->get_ok('http://localhost:3000/')->status_is(200)->content_unlike(qr{<h1>bad:
 
basic mojolicious cribsheet</h1>});

my $teststring='this-is-my-test-text';

# why is this not working?
$t->get_ok( 'http://localhost:3000/' => form => { from => 
'http://localhost:3000/', getsometext => $teststring, id => 'formget' } )
    ->status_is(200)
    ->content_like( qr{<span>$teststring</span>}ms );

# or this?
$t->post_ok( 'http://localhost:3000/' => form => { from => 
'http://localhost:3000/', 
postsometext => $teststring, id => 'formpost' } )
    ->status_is(200)
    ->content_like( qr{Post Result: <span>$teststring</span>}ms );

done_testing();


on this code

#!/usr/bin/env perl
use Mojolicious::Lite;

my $indexpage= sub {
  my $c = shift; 
  $c->render(template => 'index' );
};

get '/' => $indexpage;
post '/' => $indexpage;

app->start;

__DATA__

@@ index.html.ep
% layout 'default';
% title 'basic mojolicious cribsheet';

<h1>TITLE: <%= title %></h1>

  <h2> FORM GET </h2>

  <form action='/' method='GET' id="formget">
    <input id="getsometext" name="sometext" value="this was get" />
    <input id="getsubmit" type="submit">
  </form>

  <p>Get Result: <span><%= ($self->req->query_params->param("sometext")) || 
"no text yet" %></span></p>

  <h2> FORM POST </h2>

  <form action='/?ab=12' method='POST' id="formpost">
    <input id="postsometext" name="somepost" value="this was post" />
    <input id="postsubmit" type="submit">
  </form>

  <p>Post Result: <span><%= ($self->req->params->param("somepost")) || "no 
text yet" %></span> .<br />
   Query Params: <span><%= ($self->req->query_params->param("ab")) || "ab 
not seen" %></span></p>


@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
  </head>


  <body style="margin:3em; background-color:beige">
    <%= content %>
  </body>
</html>



-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to