Skip to content
Browse files

Catch schema() calls without a prior setup() call

Signed-off-by: Pedro Melo <melo@simplicidade.org>
  • Loading branch information...
1 parent 4fd8111 commit aab314ad073d96e5a2dc788e2cb36098691d50c5 @melo committed Jan 18, 2010
Showing with 7 additions and 0 deletions.
  1. +3 −0 lib/DBICx/Shortcuts.pm
  2. +4 −0 t/01-trouble.t
View
3 lib/DBICx/Shortcuts.pm
@@ -39,6 +39,9 @@ sub setup {
sub schema {
my $class = shift;
+
+ croak("Class '$class' did not call 'setup()'")
+ unless exists $schemas{$class};
my $info = $schemas{$class};
my $schema = $info->{schema};
View
4 t/01-trouble.t
@@ -7,6 +7,10 @@ use Test::More;
use Test::Exception;
use S2;
+throws_ok sub { DBICx::Shortcuts->schema },
+ qr/Class 'DBICx::Shortcuts' did not call 'setup[(][)]'/,
+ 'Needs to call setup() first';
+
throws_ok sub { DBICx::Shortcuts->connect_info },
qr/Class 'DBICx::Shortcuts' needs to override 'connect_info[(][)]'/,
'The connect_info() method dies by default';

0 comments on commit aab314a

Please sign in to comment.
Something went wrong with that request. Please try again.