How to Reset Expectations on an Object in Rspec

I just figured this out, and there wasn’t a lot of clear documentation online, so I’d like to get it down.

I had a case where I wanted to make sure an object did not receive a message, and then change some things, and then the object should receive a message. Well, in order to do that I had to reset the expectations on the object before I “changed things”.

Anyway, here’s the quick one-liner in case you find yourself wanting to do this too.


Hope that helps someone out there.

PS. I’ll admit this is a sign of an unconventionally written test, but let’s just ignore that for now. 🙂