Majestic Sea Creature

Technical Ramblings from Gregory Brown

Prawn moves to test-spec / Mocha from RSpec

I like RSpec . I think it leads to pretty looking tests, encourages good practices, and generally provides better tools than Test::Unit. The bad side of it is that it is too damn magical.

Nested contexts are broken on Ruby 1.9 as of right now, as you can see from this trivial example:

Okay, so that sucks, but I didn’t really care. It’s not terribly hard to avoid using nested contexts, so I’ve just been working around it. Then today when trying to integrate a simple patch that James Healy cooked up for compressing content streams, I end up with some nasty failures out of the blue on Ruby 1.9.0_3:

The specs James added were a little weird, because they make use of stubbing and instance_variable_set, but the problem with them doesn’t seem to be a Ruby 1.9 bug, so RSpec is probably to blame here.

I know first hand from working on Prawn that keeping up with Ruby 1.9 is a pain in the ass. However, taking a quick look at the RSpec Tracker and seeing 143 open bugs doesn’t give me a lot of confidence for seeing things stabilize in RSpec-land any time soon, even if most of these issues aren’t 1.9 related.

I had no idea whether it’d be fruitful or not, but I decided to try to move things over to test-spec and Mocha. As it turns out, this wasn’t too much work and now all the tests are passing on Ruby 1.9 again. As an added bonus, those who wish to submit Test::Unit code to us can do so now.

I really hope that people don’t get frustrated about the sudden change, but to me, fighting with my testing framework is about the least productive thing imaginable. Having tests that run without issues on Ruby 1.9 is a must-have for Prawn, and though YMMV, test-spec and Mocha have (for the time being), provided that for us.

Alternative Testing Frameworks FTW!

Written by Gregory Brown on 2008.08.07 at 14:04 | Responses


blog.majesticseacreature.com : Home | Archives | Feed