Joined June 2017
·

alexjunger

Posted to RSpec: allow vs expect over 1 year ago

I think your wording is a bit misleading:
allow doesn't assume that an object responds to a message, it is explicitly required. The "assume" part is about the method getting called. It might or might not get called, but when it does, you want it to return "The RSpec book"

It's the same with expect: You don't expect what the call returns, you expect the call itself - meaning that you want your test to fail if the call doesn't happen in your subject under test. And when it actually gets called, you want it to return precisely "The RSpec Book".

It's a subtle but important distinction.

Achievements
1 Karma
0 Total ProTip Views