diff options
author | Hakim Cassimally <hakim@mysociety.org> | 2014-07-15 17:14:00 +0000 |
---|---|---|
committer | Hakim Cassimally <hakim@mysociety.org> | 2014-10-16 16:56:26 +0000 |
commit | f47e9d48a2d26e92723ae96d3d65a1ba005f426f (patch) | |
tree | f456fe44e7d22b3f27cc75e5090cb5b34e5ee70a /t | |
parent | 06a69fa7a7e9fae205df36ddc68d131d91533792 (diff) |
Open311 Role for accepting default config file
See also MooX::ConfigFromFile, but that's underdocumented and
seems overengineered -- may be worth implementing if requirements
become more complex however. (See also Config::Any, which is
well worth doing in future, using YAML only reflects current
usage in FMS though.)
Diffstat (limited to 't')
-rw-r--r-- | t/open311/endpoint/config1.yml | 1 | ||||
-rw-r--r-- | t/open311/endpoint/configfile.t | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/t/open311/endpoint/config1.yml b/t/open311/endpoint/config1.yml new file mode 100644 index 000000000..c444f32c5 --- /dev/null +++ b/t/open311/endpoint/config1.yml @@ -0,0 +1 @@ +foo: baz diff --git a/t/open311/endpoint/configfile.t b/t/open311/endpoint/configfile.t new file mode 100644 index 000000000..7f41468ba --- /dev/null +++ b/t/open311/endpoint/configfile.t @@ -0,0 +1,23 @@ +use strict; use warnings; + +BEGIN { + package Foo; + use Moo; + with 'Open311::Endpoint::Role::ConfigFile'; + + has foo => ( is => 'ro', default => 'foo' ); +} + +package main; +use Test::More; + +is +Foo->new->foo, + 'foo', 'sanity'; +is +Foo->new( foo => 'bar')->foo, + 'bar', 'override'; +is +Foo->new( config_file => 't/open311/endpoint/config1.yml' )->foo, + 'baz', 'with config'; +is +Foo->new( config_file => 't/open311/endpoint/config1.yml', foo => 'qux' )->foo, + 'qux', 'with config, overridden'; + +done_testing; |