[rspec-devel] BehaviourRunner and ExampleSuite

Brian Takita brian.takita at gmail.com
Sun Sep 23 00:41:49 EDT 2007

On 9/22/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> The CHANGELOG says "Behaviour subclasses Test::Unit::TestCase".
> However, when I look in the code, the only subclass of TestCase is
> Example. There doesn't seem to be a Behaviour class at all anymore,
> but there are plenty of variables in the code named 'behaviour'
> For a long while we have been referring to "it" blocks as "examples",
> and they correspond to test_* methods in xUnit speak. Further, we used
> to call the describe blocks "behaviours" and they correspond to Test
> classes in xUnit speak.
> But now it looks like an "example" is analogous to a Test class?!?!
Currently Example is the Example instance and Behaviour is the Example
class. There is also a SharedBehaviour, which is a Module.

Both the Example Class and SharedBehaviour include ExampleApi. It
seems like ExampleApi should be renamed to Behaviour.

I think ExampleCallbacks can be merged into ExampleApi.

ExampleDefinition is used by both SharedBehaviour and the Example
class. Example is the actual instance. It is created from an

ExampleFactory probably should be renamed back to BehaviourFactory.
What do you think?

ExampleMatcher should be renamed back to BehaviourMatcher and
ExampleMatcher#example_description and should be removed as it doesn't
seem to be used anymore.

ExampleRunProxy is used by ExampleSuite run the Example block.

ExampleShouldRaiseHandler handles should_raise options.

ExampleSuite runs the Examples for the Example class.
> There are 9 (!) example_* files and it's virtually impossible to tell
> where responsibilities are. Although I'm against extensive
> documentation in code explaining how the code works internally
> (because code should be self documenting) I think we're now at a point
> where we need to add comments or clean things up bigtime.
I think things should be cleaned up to be more understandable.
The previous versions of rspec were very difficult to understand too.
There were a number of things in the wrong places that have been
untangled, and there is still more work to do.
Since things are different, this is a great opportunity to see it from
the eyes of unfamiliarity and make it easier to grok.

> I'm really confused.
> On 9/22/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> > Hi,
> >
> > I've noticed that BehaviourRunner#prepare is invoked via two different chains:
> >
> > bin/spec -> CommandLine#run -> BehaviourRunner#run -> BehaviourRunner#prepare
> > test/unit/testsuite.rb -> ExampleSute#run -> BehaviourRunner#prepare
> >
> > In one single run, #prepare gets called twice, and returns the second
> > time because of the @already_prepared check.
> >
> > This is all quite confusing to me, and the number of delegators in
> > ExampleSuite makes it even more confusing. Now that we're using
> > Test::Unit's runner it occurs to me that we should get rid of our own
> > "runner" stuff, but there still seems to be a lot of redundancy. The
> > code is plain hard to understand.
> >
> > You who've been involved in the Test::Unit refactoring - are you
> > planning to simplify things more and get rid of our own runner?
> >
> > Aslak
> >
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel

More information about the rspec-devel mailing list