Dragos Trif Dragos Trif - 1 year ago 68
Perl Question

Falling to configure Test::DBIx::Class::Schema for a Dancer2 to app

I,m trying to run a sanity test for my

app schema using

I created a
and placed in my main app directory (not inside the
folder). The file looks like this:


use Test::More 'no_plan';
use Test::DBIx::Class::Schema;
use Dancer2::Test app => ['PearlBee'];
use lib 'lib';
use lib::PearlBee::Model::Schema;

use strict;
use warnings;

# the order is important

use_ok 'Test::DBIx::Class::Schema';
#use_ok 'lib::PearlBee::Model::Schema';
use_ok 'Dancer2::Test', app => 'PearlBee';
use_ok 'lib::PearlBee::Model::Schema';# apps => ['PearlBee'];

#use_ok 'DBICx::TestDatabase';

#my $schema = DBICx::TestDatabase->new('lib::PearlBee::Model::Schema');

my $schematest = Test::DBIx::Class::Schema->new(
# required
dsn => 'dbi:mysql:PearlBee;host=localhost;', # or use schema option
namespace => 'lib::PearlBee::Model::Schema',
moniker => 'user',
# optional
username => 'root',
password => '1',
glue => 'Result',
#test_missing => 1,

columns => [


resultsets => [
qw[ User


I crashes with the following output:

Can't locate object method "connect" via package "lib::PearlBee::Model::Schema"

Please help me to make sense out of this.

Answer Source

These lines look interesting:

use lib 'lib';
use lib::PearlBee::Model::Schema;

The first one seems ok. I can see why you'd want to add 'lib' to @INC. But having done that, I'd expect the second line to be:

use PearlBee::Model::Schema;

It seems very unlikely that you'd need that lib:: on the front of the module name. But perhaps your directory structure is more complex that I'm assuming. Where is the PearlBee schema module?

Update: Also note that the latest version of the Dancer2::Test documentation says this:

DEPRECATED. Please use Plack::Test instead as shown in the SYNOPSIS!

This module will warn for a while until we actually remove it. This is to provide enough time to fully remove it from your system.

I suggest you follow that advice.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download