[LRUG] Writing readable feature tests with RSpec
Tom Stuart
tom at codon.com
Thu Jul 31 03:11:19 PDT 2014
On 31 Jul 2014, at 11:00, Scott Matthewman <scott at evvnt.com> wrote:
> In our own tests, when we're unit testing methods that are expected to return a Boolean, we use `eq(true)`, etc. to guarantee we're getting a genuine Boolean result back.
At the risk of going off on a tangent: why do you care about that? It’s very rare to use a boolean value for anything other than a truthiness check (e.g. in a conditional), and in those situations a value with the same truthiness as the corresponding boolean will work just as well.
What bad thing could happen in your code if you allowed your specs to use `be_truthy` in place of `eq(true)`? My best guess is that it’s about ensuring you don’t leak accidentally-usable objects from your predicate methods, but I’d love to hear what the real reason is.
Cheers,
-Tom
More information about the Chat
mailing list