[rspec-devel] On ExampleGroups and spec_path

Bob Cotton bob.cotton at rallydev.com
Sat Jan 12 23:23:16 EST 2008


I've got a bug open in lighthouse, 

     224: "Nested ExampleGroups do not have a spec_path"

which I realize after spending some more time with the code, that the
patch is incomplete with respect to capturing the spec_path when
creating subclasses of ExampleGroup. 

I had also seen LH#225 "Focused specs do not work with nested describes"
where Brian is talking about capturing the backtrace of ExampleGroup and
Examples.

Here my problem:

I'm trying to write a better spec_distributed, by which a custom runner
can request that any, single, ExampleGroup be run on a remote machine.

The remote runner may be serving requests from multiple sources, loading
code over network filesystems, therefore (optionally) needing to fork
for each ExampleGroup.

Therefore the remote runner needs to know the filename where
ExampleGroup is defined.

There are three forms of ExampleGroup creation where spec_path is not
being set (that I'm aware of so far):

 1. Nested describes. LH#224
 2. Subclasses of ExampleGroup (or whatever the default base class is)
 3. Block-less describes inside #2 (No bug opened yet)

#1 and #3 can be dealt with. But #2 is hard, because the "declaration"
point only comes from ExampleGroupMethods#inherited, which could be
overridden in another intermediate subclass. You have know way of
knowing how far down the call stack to look to find the "right" file.

So I may have to skip remotely running ExampleGroups created using #2
and issue a warning that inserting a block-less describe at the top of
the class would solve it. (same goes for TestCase)

Thoughts?

- Bob


More information about the rspec-devel mailing list