In phpspec2 is there any way in a spec class to change what subject class is created as the target? I'm using kohana framework, where convention is to use underscored class names rather than namespaces to map class files down a directory tree. That's valid under psr-0 but not supported by the way phpspec maps filenames back to class names when loading specs.
If I want to specify Model_User then phpspec will expect the spec file to be in spec/Model_UserSpec.php - so all my spec files would have to be in the top-level spec directory.
If I rename my class Model\User then I can have a spec\Model\User and use nested directories in both. But then other factory classes in modules and core that map strings or filenames to classes will fail to load Model\User as they'll still look for Model_User.
In other words the issue is not that the autoloader can't find the files but that it's being asked for the wrong class names because of the ambiguity in the psr0 spec.
So it should be easiest (though not really neatest) to adopt different conventions for the spec and the class to suit the different class mapping conventions. But I can't see how to indicate that spec\Model\UserSpec.php should wrap \Model_User instead. As far as I can see the spec name(and namespace) is completely tied to the subject name.
In rspec I could just implement the subject method to override the defaults - is there something similar I've missed? Otherwise it looks like I might have to implement an extension with a custom loader to handle this - but it would mean copying a lot of the PSR-0 loader and resource as the couple of bits I'd need to change are buried in private methods or protected methods that use private instance variables.
Any ideas on how I could tackle this would be very welcome, particularly if I've missed something obvious.
Thanks,
Andrew
--
You received this message because you are subscribed to a topic in the Google Groups "PHPSpec - Behavior Driven Design (BDD) for PHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phpspec-dev/KMccpQcC5yE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phpspec-dev...@googlegroups.com.
To post to this group, send email to phpsp...@googlegroups.com.
Visit this group at http://groups.google.com/group/phpspec-dev.
For more options, visit https://groups.google.com/groups/opt_out.