On Tue, Aug 19, 2008 at 11:54 PM, Scott Taylor
<mailing_lists at railsnewbie.com> wrote:
>> On Aug 19, 2008, at 8:46 PM, Pat Maddox wrote:
>>> On Tue, Aug 19, 2008 at 8:38 PM, Ben Mabey <ben at benmabey.com> wrote:
>>>>>> I know the easy thing would be to just create separate unit and
>>> functional directories.. but that is something that I would like to
>>> avoid. Besides, that is easy and I like pain. :)
>>>> Why do you want to avoid that? I think it's superior from an
>> organizational standpoint, and doesn't require screwing with the
>> runner.
>> Well, it does seem like you'd need to screw with the running just a little
> bit if you plan spec/integrationmodels and spec/unit/models to use the
> ModelExampleGroup, and so on...
Right now, what happens is the example group factory looks at the path
to the spec and sees if it matches some known type. For example, it
takes
spec/models/user_spec.rb
and parses out models. Then it looks to see if it knows of an example
group type registered to the key :model. So if you follow a naming
structure like
spec/models/unit
spec/models/integration
then it'll still work fine. Moving them around will not work though:
spec/unit/models
spec/integration/models
I don't know whether or not it's desirable to make it work
automatically for this other dir structure (which makes more sense in
my eyes anyway). At any rate, the approach I've used is to have a
spec_helper.rb in that file that sets the default example group class.
So spec/unit/models/spec_helper.rb has
Spec::Example::ExampleGroupFactory.default
Spec::Rails::Example::ModelExampleGroup
So while you're right that you do have to do something in order to
make it work, there is at least a reasonable, official way of doing
so.
Pat