pod updates and more tests v0.08
Brian Cassidy [Tue, 23 May 2006 13:20:18 +0000 (13:20 +0000)]
Changes
MANIFEST
lib/Catalyst/Plugin/ConfigLoader/Perl.pm
t/20-mock_load.t [new file with mode: 0644]
t/conf/conf.pl
t/mockapp/mockapp.pl [new file with mode: 0644]
t/mockapp/mockapp_local.pl [new file with mode: 0644]

diff --git a/Changes b/Changes
index c8eac9b..d21cc7f 100644 (file)
--- 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\r
     - added the ability to specify a MYAPP_CONFIG ENV variable\r
     - more granular merging of top-level hashrefs\r
+    - more comprehensive tests\r
 \r
 0.07  Mon May 01 2006\r
     - added Config::General support\r
index de5b36b..1addae9 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -11,6 +11,7 @@ MANIFEST
 META.yml\r
 t/01-use.t\r
 t/10-live_auto.t\r
+t/20-mock_load.t\r
 t/50-general.t\r
 t/51-ini.t\r
 t/52-json.t\r
@@ -28,4 +29,6 @@ t/conf/conf.yml
 t/lib/TestApp.pm\r
 t/lib/TestApp/testapp.pl\r
 t/lib/TestApp/Controller/Config.pm\r
+t/mockapp/mockapp.pl\r
+t/mockapp/mockapp_local.pl\r
 \r
index 5796dfd..e94edba 100644 (file)
@@ -13,10 +13,10 @@ Loads Perl files. Example:
 \r
     {\r
         name => 'TestApp',\r
-        Controller::Foo => {\r
+        'Controller::Foo' => {\r
             foo => 'bar'\r
         },\r
-        Model::Baz => {\r
+        'Model::Baz' => {\r
             qux => 'xyzzy'\r
         }\r
     }\r
diff --git a/t/20-mock_load.t b/t/20-mock_load.t
new file mode 100644 (file)
index 0000000..7f19b85
--- /dev/null
@@ -0,0 +1,42 @@
+use Test::More tests => 5;\r
+\r
+my $app = MockApp->new;\r
+$app->setup;\r
+\r
+ok( $app->config );\r
+is( $app->config->{ 'Controller::Foo' }->{ foo }, 'bar' );\r
+is( $app->config->{ 'Controller::Foo' }->{ new }, 'key' );\r
+is( $app->config->{ 'Model::Baz' }->{ qux }, 'xyzzy' );\r
+is( $app->config->{ 'Model::Baz' }->{ another }, 'new key' );\r
+\r
+package MockApp;\r
+\r
+use base qw( Catalyst::Plugin::ConfigLoader );\r
+use NEXT;\r
+use Catalyst::Utils;\r
+\r
+sub new {\r
+    return bless { }, shift;\r
+}\r
+\r
+sub path_to {\r
+    return 't/mockapp';\r
+}\r
+\r
+sub debug {\r
+    0;\r
+}\r
+\r
+sub config {\r
+    my $self = shift;\r
+    $self->{ _config } = {} unless $self->{ _config };\r
+    if (@_) {\r
+        my $config = @_ > 1 ? {@_} : $_[0];\r
+        while ( my ( $key, $val ) = each %$config ) {\r
+            $self->{ _config }->{$key} = $val;\r
+        }\r
+    }\r
+    return $self->{ _config };\r
+}\r
+\r
+1;
\ No newline at end of file
index 04707ad..8683545 100644 (file)
@@ -1,9 +1,9 @@
 {\r
     name => 'TestApp',\r
-    Controller::Foo => {\r
+    'Controller::Foo' => {\r
         foo => 'bar'\r
     },\r
-    Model::Baz => {\r
+    'Model::Baz' => {\r
         qux => 'xyzzy'\r
     }\r
 }
\ No newline at end of file
diff --git a/t/mockapp/mockapp.pl b/t/mockapp/mockapp.pl
new file mode 100644 (file)
index 0000000..8683545
--- /dev/null
@@ -0,0 +1,9 @@
+{\r
+    name => 'TestApp',\r
+    'Controller::Foo' => {\r
+        foo => 'bar'\r
+    },\r
+    'Model::Baz' => {\r
+        qux => 'xyzzy'\r
+    }\r
+}
\ No newline at end of file
diff --git a/t/mockapp/mockapp_local.pl b/t/mockapp/mockapp_local.pl
new file mode 100644 (file)
index 0000000..59913d2
--- /dev/null
@@ -0,0 +1,10 @@
+{\r
+    'Controller::Foo' => {\r
+        new => 'key'\r
+    },\r
+    Component => {\r
+        'Model::Baz' => {\r
+            'another' => 'new key'\r
+        }\r
+    }\r
+}
\ No newline at end of file