[rspec-devel] Reporter Thread Safety

Bob Cotton bob.cotton at rallydev.com
Tue Jul 17 21:41:50 EDT 2007

I'm implementing a custom formatter that needs to track the
relationship between Examples and their Behaviors. 

One way to do this is to keep an instance variable on the Reporter for
the last Behaviour that was passed to
#add_behaviour. Then I can make the association in

When working with multiple threads, I would need to change that
instance variable to a thread local to ensure that the behaviour is
the "last" behavior seen. Seems icky.

Example#run does not, that I can tell, have access to its Behaviour so
it could be passed to the reporter.

Thoughts on how to fix this? Pass the Behaviour to the Example, then
into the reporter?

I can provide a patch.

- Bob

More information about the rspec-devel mailing list