rspec/rspec-core — pull request #609 by alexch (2012-05-01 15:33:11+00:00)
Title: JSON formatter

I built an RSpec Server to communicate with a JavaScript Client, so I needed a nice way to send back the results. Thus was born JsonFormatter!

I've still got one big bug -- it can't be run more than once in the same process. I suspect an output stream reference is being set in one of the RSpec globals, so I'll have to track that down and make sure it's reset to point to the real StringIO output stream instead of whatever output stream was set on the first run. But it seems to work ok in normal (command-line, one run at a time) use.

I also made the code work more gracefully when run in $SAFE mode. It looks like you've already got some policies of returning nil on failure in the libraries I was working in so I think that's kosher; otherwise a low-level SecurityError will be thrown and ruin your whole day.