I have a factory class which provides a bunch of similar methods by using autoload. For a longer list of different object types it can do things like
Factory->objects();
Factory->object(23);
Factory->object(name => "foo");
Now I want to write a test for this class. I started with something like this:
use Test::More;
BEGIN { use_ok 'Factory' }
my $objects = Factory->objects;
# more tests following ...
The test fails in the line with Factory->objects
because it implicitly checks if Factory
can do objects()
. I could not find some documentation for this. But if I run the same call in a non-testing script it works perfectly.
How to test this?
Update: ARGH, I've just recognized I put all of this in the test for the Factory
model class in my Catalyst app. Well, this model class is an Adapter for the Factory
class in my external model (which I actually intended to test). The work perfectly for the model itself. Still would appreciate to know how to test method from an adapted class. This is how the adapter class looks like:
package MyCatalystApp::Model::Factory;
use Moose;
extends 'Catalyst::Model';
extends 'Catalyst::Model::Adaptor';
__PACKAGE__->config(class => 'MyModel::Factory');
MyModel::Factory
is the same class as Factory
in the original question. I skipped the difference between Catalyst and the model in the original question for simplification.