I was happily mocking away with Mocha, then I passed a stub to a case statement at which point I was a little flummoxed.
The Ruby documentation clearly states that the ‘when’ in a ‘case’ statement uses the ‘===’ method for comparing the subject so I couldn’t work out why something like the following wasn’t working:
So I had a little play around in irb and found the following:
This revealed that I was actually stubbing the wrong side of the operator, I changed this to the following and voila!
Looks obvious now but certainly wasn’t at the time!