From: Brian Cassidy Date: Tue, 23 May 2006 13:20:18 +0000 (+0000) Subject: pod updates and more tests X-Git-Tag: v0.08^0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Plugin-ConfigLoader.git;a=commitdiff_plain;h=refs%2Ftags%2Fv0.08 pod updates and more tests --- diff --git a/Changes b/Changes index c8eac9b..d21cc7f 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ Revision history for Perl extension Catalyst::Plugin::ConfigLoader. - added get_config_path() which extracts the path finding code - added the ability to specify a MYAPP_CONFIG ENV variable - more granular merging of top-level hashrefs + - more comprehensive tests 0.07 Mon May 01 2006 - added Config::General support diff --git a/MANIFEST b/MANIFEST index de5b36b..1addae9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -11,6 +11,7 @@ MANIFEST META.yml t/01-use.t t/10-live_auto.t +t/20-mock_load.t t/50-general.t t/51-ini.t t/52-json.t @@ -28,4 +29,6 @@ t/conf/conf.yml t/lib/TestApp.pm t/lib/TestApp/testapp.pl t/lib/TestApp/Controller/Config.pm +t/mockapp/mockapp.pl +t/mockapp/mockapp_local.pl diff --git a/lib/Catalyst/Plugin/ConfigLoader/Perl.pm b/lib/Catalyst/Plugin/ConfigLoader/Perl.pm index 5796dfd..e94edba 100644 --- a/lib/Catalyst/Plugin/ConfigLoader/Perl.pm +++ b/lib/Catalyst/Plugin/ConfigLoader/Perl.pm @@ -13,10 +13,10 @@ Loads Perl files. Example: { name => 'TestApp', - Controller::Foo => { + 'Controller::Foo' => { foo => 'bar' }, - Model::Baz => { + 'Model::Baz' => { qux => 'xyzzy' } } diff --git a/t/20-mock_load.t b/t/20-mock_load.t new file mode 100644 index 0000000..7f19b85 --- /dev/null +++ b/t/20-mock_load.t @@ -0,0 +1,42 @@ +use Test::More tests => 5; + +my $app = MockApp->new; +$app->setup; + +ok( $app->config ); +is( $app->config->{ 'Controller::Foo' }->{ foo }, 'bar' ); +is( $app->config->{ 'Controller::Foo' }->{ new }, 'key' ); +is( $app->config->{ 'Model::Baz' }->{ qux }, 'xyzzy' ); +is( $app->config->{ 'Model::Baz' }->{ another }, 'new key' ); + +package MockApp; + +use base qw( Catalyst::Plugin::ConfigLoader ); +use NEXT; +use Catalyst::Utils; + +sub new { + return bless { }, shift; +} + +sub path_to { + return 't/mockapp'; +} + +sub debug { + 0; +} + +sub config { + my $self = shift; + $self->{ _config } = {} unless $self->{ _config }; + if (@_) { + my $config = @_ > 1 ? {@_} : $_[0]; + while ( my ( $key, $val ) = each %$config ) { + $self->{ _config }->{$key} = $val; + } + } + return $self->{ _config }; +} + +1; \ No newline at end of file diff --git a/t/conf/conf.pl b/t/conf/conf.pl index 04707ad..8683545 100644 --- a/t/conf/conf.pl +++ b/t/conf/conf.pl @@ -1,9 +1,9 @@ { name => 'TestApp', - Controller::Foo => { + 'Controller::Foo' => { foo => 'bar' }, - Model::Baz => { + 'Model::Baz' => { qux => 'xyzzy' } } \ No newline at end of file diff --git a/t/mockapp/mockapp.pl b/t/mockapp/mockapp.pl new file mode 100644 index 0000000..8683545 --- /dev/null +++ b/t/mockapp/mockapp.pl @@ -0,0 +1,9 @@ +{ + name => 'TestApp', + 'Controller::Foo' => { + foo => 'bar' + }, + 'Model::Baz' => { + qux => 'xyzzy' + } +} \ No newline at end of file diff --git a/t/mockapp/mockapp_local.pl b/t/mockapp/mockapp_local.pl new file mode 100644 index 0000000..59913d2 --- /dev/null +++ b/t/mockapp/mockapp_local.pl @@ -0,0 +1,10 @@ +{ + 'Controller::Foo' => { + new => 'key' + }, + Component => { + 'Model::Baz' => { + 'another' => 'new key' + } + } +} \ No newline at end of file