Testing code that integrates with Rspec

Hey all,

I’ve been using Rspec for a while now, but this is the first time I’ve
run
up against the following problem: how do you use Rspec to test code that
uses Rspec?

Basically my code takes as input a representation of example groups, and
it
should dynamically create those example groups and then run them. I
borrowed
this code from a open-source project that doesn’t appear to have tests
for
it; the code works, but I’d like to get it under test so I can improve
it.

Going through the Rspec code (v 1.3.0), it appears that this should be
possible. There’s Spec::runner::Options, which looks to be a decent
entry
point for kicking off an Rspec run (with #run_examples). It has
something
attached to it called a Reporter, which looks like an observer that, if
I
could mock it, I could sense exactly what my run of Rspec did.

Unfortunately, when I wrote a spec to invoke this code, both the code
under
test and the spec itself seemed to talk to the same Reporter (the one
that
got created first, for the the spec). So my spec and my code are
entangled.

Any suggestions?

Here’s a gist with a stripped down version of my code and a description
of
what output it produced. I can work on this gist to make it actually
runnable if anybody is interested.

Thanks a bunch,
Mike

Oops, forgot the gist:

Thanks,
Mike