Allow me to introduce the given keyword / function, written for use with specs2. It allows you to turn code like this:
Much better right? I find that the version that uses given is more readable, as it is better at communicating its intent. The intent is effectively always to put the spotlight on a value in order to inspect various aspects of it. In our example above, for instance, the spotlight was on the response.
It is also possible to nest the givens:
The implementation of given it-self is quite simple:
Enjoy testing with given! Before you know it you’ll be addicted!