Is there a way to unstub in RSpec?

With new expect syntax, unstub is deprecated. You can do:

# stub
allow(SomeClass).to receive(:a_method)

# do something...

# unstub
allow(SomeClass).to receive(:a_method).and_call_original

If the first allow contains .with or a block, I believe it’ll still carry to the next call, so the next allow doesn’t clear those things.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)