Robert Shecter

Ruby RSpec or Minitest on new projects?

I’ve used both for years. But now I’m using RSpec on my new projects.

Contents

  • RSpec is an application, but Minitest is just a library
  • RSpec has incredible, auto-generated documentation
  • RSpec has first-class spec syntax support
  • RSpec, out of the box, has all the features a working developer needs.

RSpec is an application, but Minitest is just a library

I don’t think this can be overstated. RSpec has libraries too, of course, but the user experience is via a mature CLI program. (Bisect is wicked, and a life-saver!) It has incredibly useful options and features that are all described like you’d expect, via the --help option.

But since Minitest is just a library, it needs something else to run it. Usually, that’s Rake. Result: the user experience is nowhere near as good because Rake is just a simple task runner. Simple features like “run all tests” require custom Rake DSL coding. (!) IIRC, simple tasks like running one test or one test file are also difficult to do in Minitest.

RSpec has incredible, auto-generated documentation

Poking around in the auto-generated straight-from-cucumber docs, I’m always impressed with the readability. It’s documented by example. (Every feature has an example because this is literate code.)

I’ve never found a Minitest resource that comes close. And personally, when I’m using a framework — Minitest or RSpec — that has its own unique DSL and practices, good docs are crucial.

RSpec has first-class spec syntax support

It’s the only syntax, and it’s a pleasure to use. It’s the lingua franca of testing: my Ruby tests look just like my Haskell tests.

Minitest, in contrast, has a spec syntax option. It’s also not supported as well as the standard minitest syntax. Minitest’s spec docs are even more primitive than the standard docs. (Notice how they’re not actually documented — they just link to the equivalent Minitest function. So you need to bounce back and forth, and learn the other syntax even if you don’t use it.)

RSpec, out of the box, has all the features a working developer needs.

And so they’re all core to the project, and all have first class support.

Minitest advocates will say that there are plugins for any feature that RSpec has, and they’re listed in the README. When I checked it, though, I found that list to be more of a graveyard than a shipyard. Many (most?) were old or broken. There are no links to the plugins. Finding the ones in good shape would be a new task for me. And then, of course, there’s a risk that any of them can stop being maintained at any time.

Leave a comment