Scott Wiersdorf
2018-09-27 14:48:06 UTC
I have a package Foo that implements a Mojolicious::Lite application. It
has some default configuration. I instantiate this app via Test::Mojo and
attempt to override the configuration, but the old (default) value is
always used instead:
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;
package Foo;
use Mojolicious::Lite -signatures;
plugin Config => {default => {jack => 'squat'}};
get '/' => sub ($c) { $c->render(text => $c->app->config->{jack}) };
package main;
my $t = Test::Mojo->new(Foo => {jack => 'flack'});
$t->get_ok('/')
->content_is('flack')
->or(sub { say STDERR $t->app->dumper(shift->tx->res->body) });
done_testing();
I've tried this same technique putting the Foo class in a separate file,
putting the configuration into a file (i.e., not using the `default`
attribute for Config), etc. and it always comes down to the override
configuration isn't being used by the app. Anyone have any ideas?
Scott
has some default configuration. I instantiate this app via Test::Mojo and
attempt to override the configuration, but the old (default) value is
always used instead:
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;
package Foo;
use Mojolicious::Lite -signatures;
plugin Config => {default => {jack => 'squat'}};
get '/' => sub ($c) { $c->render(text => $c->app->config->{jack}) };
package main;
my $t = Test::Mojo->new(Foo => {jack => 'flack'});
$t->get_ok('/')
->content_is('flack')
->or(sub { say STDERR $t->app->dumper(shift->tx->res->body) });
done_testing();
I've tried this same technique putting the Foo class in a separate file,
putting the configuration into a file (i.e., not using the `default`
attribute for Config), etc. and it always comes down to the override
configuration isn't being used by the app. Anyone have any ideas?
Scott
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.