Unstub in the `then` clause
nhorton opened this issue · comments
Noah Horton commented
First off, I have to say again how much i appreciate the work on Mocha and your follow-up on issues - its amazing.
I have a scenario where there is either a feature request or an approach I am missing.
I am trying to write a test for something that deletes a set of ActiveRecord records. I need to simulate one of them having a problem and the delete failing.
The ideal way of doing it would be:
MyClass.any_instance.stubs(:destroy!).raises(PG:ForeignKeyViolation).then(unstub)
Because that would actually let most of the destroys get through, but one would get caught and a raise would happen.
Thanks again!