Shoulda and assert{2.0} make swell bedfellows
I have been generally using RSpec for my testing needs, but I’ve recently been persuaded to use Shoulda on a few projects.
For most things, they seem about on par.
One thing I missed in particular was the ‘should’ syntax of RSpec, like:
As opposed to using test-unit’s:
I haven’t been able to entirely quantify why I prefer the former syntax, but I think it has to do with more succinctly expressing the assertion.
While I haven’t found quite to replace that style syntax, I do have something that fits my craving: assert {2.0}. This gives us something like:
I think I’m actually digging this over the other two styles, because:
- If you can come up with an expression, you can assert it.
- Nice output when the assertion fails.