From: Laufeyjarson Date: Thu, 26 Jun 2014 06:09:18 +0000 (-0700) Subject: Add 'lazy' to two parameters to let the constructor runs first and set the applicatio... X-Git-Tag: 5.90070~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=7beb191e8464dabcb00f65c8e4867c5c3f7198d5 Add 'lazy' to two parameters to let the constructor runs first and set the application name properly before they are used. Without this, the command line options are sometimes ignored. One test had to change, as it assumed the port number would have been set, when the method was never called. Calling the method to get the port number fixes this, by allowing the lazy method to actually be run before the value is used. --- diff --git a/lib/Catalyst/Script/Server.pm b/lib/Catalyst/Script/Server.pm index 5f0ac06..983a995 100644 --- a/lib/Catalyst/Script/Server.pm +++ b/lib/Catalyst/Script/Server.pm @@ -37,6 +37,7 @@ has port => ( cmd_aliases => 'p', isa => 'Int', is => 'ro', + lazy => 1, default => sub { Catalyst::Utils::env_value(shift->application_name, 'port') || 3000 }, @@ -107,6 +108,7 @@ has restart => ( cmd_aliases => 'r', isa => 'Bool', is => 'ro', + lazy => 1, default => sub { Catalyst::Utils::env_value(shift->application_name, 'reload') || 0; }, diff --git a/t/aggregate/unit_core_script_server.t b/t/aggregate/unit_core_script_server.t index b096c42..c4d3c5b 100644 --- a/t/aggregate/unit_core_script_server.t +++ b/t/aggregate/unit_core_script_server.t @@ -151,7 +151,7 @@ sub testBackgroundOptionWithFork { ## Check a few args is_deeply $app->{ARGV}, $argstring; - is $app->{port}, '3000'; + is $app->port, '3000'; is($app->{background}, 1); }