[rspec-devel] The Reporter -> Formatter interface

Bob Cotton bob.cotton at rallydev.com
Thu Dec 13 17:50:56 EST 2007

Before 1.1.0 gos out, I would like to propose a change to the interface
of Formatter, and possibly Reporter. As the Formatter interface has
already changed in 1.1.0, I would like to get this in now.

I have on more then one occasion, in a custom Formatter, need to track
the association between the "active" ExampleGroup and the currently
passing/failing/pending Example. 

I believe this is caused by the fact that Examples have no knowledge of
the ExampleGroup that they belong to.

This can be see in Spec::Runner::Formatter which tracks a list of
ExampleGroups so that in Formatter#example_pending, it may pass in the
description of the ExampleGroup that the example belongs to.

My proposal is to change the interface of Formatter such that whenever
an Example is passed in, the ExampleGroup that Example belongs to is
also passed in. This would change the signature of these methods:


to all take an example_group as the fist parameter.

This could be accomplished by having the Reporter simply pass the last
ExampleGroup it has seen to the Formatter. However this is not

I don't have any mult-threaded requirements at the moment, so I'm not
proposing that the Example -> Formatter interaction needs to know about
their ExampleGroup.

I have time to finish this work, and can have a patch in a day or two.


- Bob

More information about the rspec-devel mailing list