[Catalyst-commits] r6991 - in trunk/Catalyst-View-Mason/t: . lib
lib/TestApp/View/Mason
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Mon Oct 15 15:37:10 GMT 2007
Author: rafl
Date: 2007-10-15 15:37:10 +0100 (Mon, 15 Oct 2007)
New Revision: 6991
Added:
trunk/Catalyst-View-Mason/t/comp_root_ref.t
trunk/Catalyst-View-Mason/t/lib/TestApp/View/Mason/CompRootRef.pm
Modified:
trunk/Catalyst-View-Mason/t/lib/TestApp.pm
Log:
Test comp_root stringification.
Added: trunk/Catalyst-View-Mason/t/comp_root_ref.t
===================================================================
--- trunk/Catalyst-View-Mason/t/comp_root_ref.t (rev 0)
+++ trunk/Catalyst-View-Mason/t/comp_root_ref.t 2007-10-15 14:37:10 UTC (rev 6991)
@@ -0,0 +1,58 @@
+#!perl
+
+use strict;
+use warnings;
+use Scalar::Util qw/blessed/;
+use Test::More;
+
+eval 'use Test::MockObject::Extends';
+plan skip_all => 'Test::MockObject::Extends required' if $@;
+
+eval 'use Test::MockModule';
+plan skip_all => 'Test::MockObject required' if $@;
+
+eval 'use Test::Exception';
+plan skip_all => 'Test::Exception required' if $@;
+
+plan tests => 5;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use TestApp::View::Mason::CompRootRef;
+
+my @comp_roots = (
+ { a => 1, },
+ \do { my $o = 1 },
+ sub { },
+ \*STDIN,
+);
+
+my $c = Test::MockObject::Extends->new('Catalyst');
+
+$c->mock('config' => sub {
+ return {};
+});
+
+{
+ my $log = Test::MockObject->new(\do { my $o });
+ $log->set_true(qw/debug info warn error fatal is_debug/);
+
+ $c->mock('log' => sub {
+ return $log;
+ });
+}
+
+for my $comp_root (@comp_roots) {
+ my $str = $comp_root . q//;
+
+ throws_ok(sub {
+ TestApp::View::Mason::CompRootRef->new($c, {comp_root => $comp_root});
+ }, qr/comp_root path '\Q$str\E'/, 'exception when passing '. ref($comp_root) .' reference as comp_root');
+}
+
+lives_ok(sub {
+ TestApp::View::Mason::CompRootRef->new($c, {
+ comp_root => [ [MAIN => $FindBin::Bin] ],
+ });
+}, "array root as comp_root doesn't get stringified");
Added: trunk/Catalyst-View-Mason/t/lib/TestApp/View/Mason/CompRootRef.pm
===================================================================
--- trunk/Catalyst-View-Mason/t/lib/TestApp/View/Mason/CompRootRef.pm (rev 0)
+++ trunk/Catalyst-View-Mason/t/lib/TestApp/View/Mason/CompRootRef.pm 2007-10-15 14:37:10 UTC (rev 6991)
@@ -0,0 +1,7 @@
+package TestApp::View::Mason::CompRootRef;
+
+use strict;
+use warnings;
+use base 'Catalyst::View::Mason';
+
+1;
Modified: trunk/Catalyst-View-Mason/t/lib/TestApp.pm
===================================================================
--- trunk/Catalyst-View-Mason/t/lib/TestApp.pm 2007-10-15 10:49:03 UTC (rev 6990)
+++ trunk/Catalyst-View-Mason/t/lib/TestApp.pm 2007-10-15 14:37:10 UTC (rev 6991)
@@ -21,6 +21,12 @@
__PACKAGE__->config(root => __PACKAGE__->config->{root}->stringify);
}
+__PACKAGE__->config(
+ setup_components => {
+ except => qr/^View::Mason::CompRootRef$/,
+ },
+);
+
__PACKAGE__->log( $::fake_log || Catalyst::Log->new(qw/debug info error fatal/) );
__PACKAGE__->setup;
More information about the Catalyst-commits
mailing list