From: Zbigniew Lukasiak Date: Fri, 13 Aug 2010 13:47:31 +0000 (+0100) Subject: Test for default value in a sub X-Git-Tag: 0.08~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b80c2ec1ff4cb032d3aab802efbc6546dcfd53b6;p=gitmo%2FMooseX-SimpleConfig.git Test for default value in a sub --- diff --git a/t/11default.t b/t/11default.t index aaacca2..1c17662 100644 --- a/t/11default.t +++ b/t/11default.t @@ -17,9 +17,10 @@ BEGIN { } } - plan tests => 5; + plan tests => 7; use_ok('MXDefaultConfigTest'); + use_ok('MXDefaultWithSubConfigTest'); } # Can it load a simple YAML file with the options @@ -39,6 +40,12 @@ BEGIN { is($foo->req_attr, 'foo', 'req_attr works'); is($foo->direct_attr, 123, 'direct_attr works'); is($foo->inherited_ro_attr, 'asdf', 'inherited_ro_attr works'); + + $foo = eval { + MXDefaultWithSubConfigTest->new_with_config(); + }; + ok(!$@, 'Did not die with good YAML configfile') + or diag $@; } END { unlink('test.yaml') } diff --git a/t/lib/MXDefaultWithSubConfigTest.pm b/t/lib/MXDefaultWithSubConfigTest.pm new file mode 100644 index 0000000..7703775 --- /dev/null +++ b/t/lib/MXDefaultWithSubConfigTest.pm @@ -0,0 +1,15 @@ +package MXDefaultWithSubConfigTest; +use Moose; +with 'MooseX::SimpleConfig'; + +use Path::Class::File; + +has 'direct_attr' => (is => 'ro', isa => 'Int'); + +has 'req_attr' => (is => 'rw', isa => 'Str', required => 1); + +has '+configfile' => ( default => sub { [ 'test.yaml' ] } ); +#has '+configfile' => ( default => 'test.yaml' ); + +no Moose; +1;