Greetings,

I'm new to Mojo and I'm going through the documentation. In the Growing
guide I'm trying the first testing example using login.t
(http://mojolicio.us/perldoc/Mojolicious/Guides/Growing#Testing). The
document does not specify what the results are supposed to be. When I
run the test I get a lot of failures which makes me think I've done
something wrong.  Have I?

./drmain.pl test t/login.t t/login.t .. 1/? # Failed test 'element for selector "form input[name="user"]" exists'
#   at t/login.t line 13.

#   Failed test 'element for selector "form input[name="pass"]" exists'
#   at t/login.t line 13.

#   Failed test 'element for selector "form input[type="submit"]" exists'
#   at t/login.t line 13.

#   Failed test 'similar match for selector "html body"'
#   at t/login.t line 20.
#                   ''
#     doesn't match '(?-xism:Welcome sri)'

#   Failed test '200 OK'
#   at t/login.t line 24.
#          got: '404'
#     expected: '200'

#   Failed test 'similar match for selector "a"'
#   at t/login.t line 24.
#                   ''
#     doesn't match '(?-xism:Logout)'

#   Failed test '200 OK'
#   at t/login.t line 27.
#          got: '404'
#     expected: '200'

#   Failed test 'element for selector "form input[name="user"]" exists'
#   at t/login.t line 27.

#   Failed test 'element for selector "form input[name="pass"]" exists'
#   at t/login.t line 27.

#   Failed test 'element for selector "form input[type="submit"]" exists'
#   at t/login.t line 27.
# Looks like you failed 10 tests of 16.
t/login.t .. Dubious, test returned 10 (wstat 2560, 0xa00)
Failed 10/16 subtests
Test Summary Report
-------------------
t/login.t (Wstat: 2560 Tests: 16 Failed: 10)
  Failed tests:  3-5, 8, 10-11, 13-16
  Non-zero exit status: 10
Files=1, Tests=16,  1 wallclock secs ( 0.01 usr  0.01 sys +  0.24 cusr  0.00 
csys =  0.26 CPU)
Result: FAIL
Failed 1/1 test programs. 10/16 subtests failed.

$ cat drmain.pl #!/usr/bin/env perl
use Mojolicious::Lite;

use lib 'lib';
use MyUsers;

# Helper to lazy initialize and store our model object
helper users => sub { state $users = MyUsers->new };

# /?user=sri&pass=secr3t
any '/' => sub {
  my $self = shift;

  # Query parameters
  my $user = $self->param('user') || '';
  my $pass = $self->param('pass') || '';

  # Check password
  return $self->render(text => "Welcome $user.")
    if $self->users->check($user, $pass);

  # Failed
  $self->render(text => 'Wrong username or password.');
};

app->start;

--
Neil Watson
Linux/UNIX Consultant
http://watson-wilson.ca

--
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to