Skip to content

Instantly share code, notes, and snippets.

@KES777
Created November 3, 2017 14:52
Show Gist options
  • Save KES777/1f97c941554dc67e157d6a26099c4406 to your computer and use it in GitHub Desktop.
Save KES777/1f97c941554dc67e157d6a26099c4406 to your computer and use it in GitHub Desktop.
diff --git a/lib/Mojolicious/Lite.pm b/lib/Mojolicious/Lite.pm
index cf3cd04..21277fb 100644
--- a/lib/Mojolicious/Lite.pm
+++ b/lib/Mojolicious/Lite.pm
@@ -46,9 +46,6 @@ sub import {
plugin => sub { $app->plugin(@_) },
under => sub { $routes = $root->under(@_) };
- # Make sure there's a default application for testing
- Mojo::UserAgent::Server->app($app) unless Mojo::UserAgent::Server->app;
-
# Lite apps are strict!
unshift @_, 'Mojo::Base', -strict;
goto &Mojo::Base::import;
diff --git a/lib/Test/Mojo.pm b/lib/Test/Mojo.pm
index d4b7c3b..f54cae6 100644
--- a/lib/Test/Mojo.pm
+++ b/lib/Test/Mojo.pm
@@ -241,9 +241,13 @@ sub message_unlike {
sub new {
my $self = shift->SUPER::new;
- return $self unless my $app = shift;
-
+ my $app = shift;
my @args = @_ ? {config => {config_override => 1, %{shift()}}} : ();
+
+ # Make sure there's a default application for testing
+ my $caller = caller->can( 'app' );
+ $app //= $caller->(); # Default app is from caller namespace
+
return $self->app(
ref $app ? $app : Mojo::Server->new->build_app($app, @args));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment