Created
May 23, 2018 11:08
-
-
Save KES777/b92c80959a61996063f1a3532b11f6ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojo::Base -strict; | |
use Test::Mojo; | |
use Test::More; | |
use Mojolicious::Lite; | |
app->defaults( handler => 'my_handler' ); | |
get '/example' => sub{ die }; | |
hook before_render => sub { | |
my( $c, $a ) = @_; | |
my $s = $c->stash; | |
# Because { handler } is changed between probes while `_fallbacks` | |
# we can not get original value for { handler } | |
# TODO: Keep the stash in same state when exception occur for each render_maybe | |
$s->{ result } .= $a->{ template } | |
.': ah:'.$a->{ handler } .' af:' .$a->{ format } | |
.': sh:'.$s->{ handler } .' sf:' .$s->{ format } ."\n"; | |
}; | |
my $t = Test::Mojo->new; | |
$t->get_ok( '/example.json' )->content_is( <<TEXT ); | |
exception.development: ah: af:json sh:my_handler sf:json | |
exception: ah: af:json sh:my_handler sf:json | |
exception.development: ah: af:html sh:my_handler sf:json | |
exception: ah: af:html sh:my_handler sf:json | |
TEXT | |
__DATA__ | |
@@ exception.html.ep | |
%= stash->{ result } | |
__END__ | |
ok 1 - GET /example.json | |
not ok 2 - exact match for content | |
# Failed test 'exact match for content' | |
# at t/format.t line 21. | |
# got: 'exception.development: ah: af:json: sh:my_handler sf:json | |
# exception: ah: af:json: sh: sf:json | |
# exception.development: ah: af:html: sh: sf:json | |
# exception: ah: af:html: sh: sf:html | |
# | |
# ' | |
# expected: 'exception.development: ah: af:json sh:my_handler sf:json | |
# exception: ah: af:json sh:my_handler sf:json | |
# exception.development: ah: af:html sh:my_handler sf:json | |
# exception: ah: af:html sh:my_handler sf:json | |
# | |
# ' | |
# Tests were run but no plan was declared and done_testing() was not seen. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment