Skip to content

Commit

Permalink
more complete test examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 25, 2015
1 parent c1482df commit 3607bdd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Test/Mojo.pm
Expand Up @@ -510,11 +510,11 @@ User agent used for testing, defaults to a L<Mojo::UserAgent> object.
# Allow redirects
$t->ua->max_redirects(10);
$t->get_ok('/redirect')->status_is(200);
$t->get_ok('/redirect')->status_is(200)->content_like(qr/redirected/);
# Switch protocol from HTTP to HTTPS
$t->ua->server->url('https');
$t->get_ok('/secure')->status_is(200);
$t->get_ok('/secure')->status_is(200)->content_like(qr/secure/);
# Use absolute URL for request with Basic authentication
my $url = $t->ua->server->url->userinfo('sri:secr3t')->path('/secrets.json');
Expand All @@ -527,6 +527,7 @@ User agent used for testing, defaults to a L<Mojo::UserAgent> object.
my ($ua, $tx) = @_;
$tx->req->headers->accept_language('en-US');
});
$t->get_ok('/hello')->status_is(200)->content_like(qr/Howdy/);
=head1 METHODS
Expand Down Expand Up @@ -557,10 +558,13 @@ Access application with L<Mojo::UserAgent::Server/"app">.
$c->render(text => 'This request did not reach the router.')
if $c->req->url->path->contains('/user');
});
$t->get_ok('/user')->status_is(200)->content_like(qr/not reach the router/);
# Extract additional information
my $stash;
$t->app->hook(after_dispatch => sub { $stash = shift->stash });
$t->get_ok('/hello')->status_is(200);
is $stash->{foo}, 'bar', 'right value';
=head2 content_is
Expand Down

0 comments on commit 3607bdd

Please sign in to comment.