Skip to content

Commit

Permalink
a few more exception tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 13, 2013
1 parent 776ed11 commit f17c8b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -2,6 +2,7 @@
3.96 2013-04-14
- Improved default descriptions in Test::Mojo.
- Improved documentation.
- Improved tests.

3.95 2013-04-12
- Added finished_ok method to Test::Mojo.
Expand Down
11 changes: 8 additions & 3 deletions t/mojolicious/exception_lite_app.t
Expand Up @@ -64,12 +64,13 @@ get '/trapped/too' => sub {
$self->render_text("$@" || 'failed');
};

# Reuse exception
my $exception;
# Reuse exception and snapshot
my ($exception, $snapshot);
hook after_dispatch => sub {
my $self = shift;
return unless $self->req->url->path->contains('/reuse/exception');
$exception = $self->stash('exception');
$snapshot = $self->stash('snapshot');
};

# Custom exception handling
Expand All @@ -81,7 +82,8 @@ hook around_dispatch => sub {
}
};

get '/reuse/exception' => sub { die "Reusable exception.\n" };
get '/reuse/exception' => {foo => 'bar'} =>
sub { die "Reusable exception.\n" };

get '/custom' => sub { die "CUSTOM\n" };

Expand Down Expand Up @@ -182,10 +184,13 @@ $t->get_ok('/missing_template.json')->status_is(404)

# Reuse exception
ok !$exception, 'no exception';
ok !$snapshot, 'no snapshot';
$t->get_ok('/reuse/exception')->status_is(500)
->content_like(qr/Reusable exception/);
isa_ok $exception, 'Mojo::Exception', 'right exception class';
like $exception, qr/Reusable exception/, 'right exception';
is $snapshot->{foo}, 'bar', 'right snapshot value';
ok !$snapshot->{exception}, 'no exception in snapshot';

# Bundled static files
$t->get_ok('/mojo/jquery/jquery.js')->status_is(200)
Expand Down

0 comments on commit f17c8b7

Please sign in to comment.