Created
March 30, 2018 06:54
-
-
Save KES777/1d44fa16ece82f7f71b33a70f933b764 to your computer and use it in GitHub Desktop.
Mojolicous expects wrong results
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 Mojolicious::Lite; | |
use Test::Mojo; | |
use Test::More; | |
hook before_render => sub { | |
my ($c, $args) = @_; | |
@$args{qw(text format)} = ($args->{exception}, 'txt') | |
if ($args->{template} // '') eq 'exception' && $c->accepts('txt'); | |
}; | |
get '/dead_action' => sub { die "dead action!\n" }; | |
my $t = Test::Mojo->new; | |
# Because client accepts nothing Mojolicious fallback to 'txt': | |
# https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Renderer.pm#L37 | |
$t->get_ok('/dead_action')->status_is(500) | |
->content_type_is('text/plain;charset=UTF-8') | |
->content_is("dead action!\n"); | |
done_testing; | |
__END__ | |
ok 1 - GET /dead_action | |
ok 2 - 500 Internal Server Error | |
not ok 3 - Content-Type: text/plain;charset=UTF-8 | |
# Failed test 'Content-Type: text/plain;charset=UTF-8' | |
# at t/mojolicious/exception_lite_app2.t line 18. | |
# got: 'text/html;charset=UTF-8' | |
# expected: 'text/plain;charset=UTF-8' | |
not ok 4 - exact match for content | |
# Failed test 'exact match for content' | |
# at t/mojolicious/exception_lite_app2.t line 18. | |
# got: 'dead action! | |
# | |
# ' | |
# expected: 'dead action! | |
# ' | |
1..4 | |
# Looks like you failed 2 tests of 4. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment