OK. May be you don't understand me because of my bad English. I'll try
another way.
How can I change this test in 1-2 lines, or this is a bug?
(
https://gist.github.com/fefdf621a917ede71a74)
#!/usr/bin/env perl
use Mojo::Base -strict;
use Test::More 'no_plan';
use Mojolicious;
use Test::Mojo;
use File::Temp qw/tempdir/;
use IO::File;
sub e_app {
# Simple app
my $eapp = Mojolicious->new();
$eapp->routes->route('/test')->to(cb => sub {
shift->render_text('emb') });
return $eapp;
}
sub p_app {
my ($embedded, $host) = @_;
# Parent app with embedded on emb.host
my $app = Mojolicious->new();
# virtual hosting. Embedded app
$app->routes->route('/')->over(host => $host)->detour($embedded);
$app->routes->route('/test')->to(cb => sub {
shift->render_text('parent') });
return $app;
}
# Parent and child, embedded via host emb.host.
my $E_HOST = 'sub.host';
my $e_app = e_app;
my $p_app = p_app($e_app => $E_HOST);
# test our virtual host logic.
Test::Mojo->new()->app($p_app)->get_ok("/test")->content_is('parent');
Test::Mojo->new()->app($p_app)->get_ok("/test", {Host => $E_HOST})
->content_is('emb');
# create our own favicon for embedded app
my $pub = $e_app->static->paths->[0] = tempdir;
IO::File->new(do { join '/', $pub, 'favicon.ico' }, 'w')->print('popa');
# /favicon.ico must be different now!!!!!!!!!!!!
Test::Mojo->new()->app($e_app)->get_ok('/favicon.ico')->content_is('popa');
Test::Mojo->new()->app($p_app)->get_ok('/favicon.ico',, {Host => $E_HOST})
->content_is('popa');