Skip to content

Commit

Permalink
added another advanced testing example
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 13, 2012
1 parent 628330b commit 173953f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Test/Mojo.pm
Expand Up @@ -417,7 +417,7 @@ Current transaction, usually a L<Mojo::Transaction::HTTP> object.
ok $t->tx->res->is_multipart, 'multipart content';
# Test custom transaction
my $tx = $t->ua->build_form_tx('/users' => {name => 'sri', id => 99});
my $tx = $t->ua->build_form_tx('/user/99' => {name => 'sri'});
$tx->req->method('PUT');
$t->tx($t->ua->start($tx))
->status_is(200)
Expand Down Expand Up @@ -469,6 +469,13 @@ Alias for L<Mojo::UserAgent/"app">.
is $t->app->defaults->{foo}, 'bar', 'right value';
ok $t->app->routes->find('echo')->is_websocket, 'WebSocket route';
# Change application behavior
$t->app->hook(before_dispatch => sub {
my $self = shift;
$self->render(text => 'This request did not reach the router.')
if $self->req->url->path->contains('/user');
});
=head2 C<content_is>
$t = $t->content_is('working!');
Expand Down

0 comments on commit 173953f

Please sign in to comment.