Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unstub in the then clause #618

Open
nhorton opened this issue Sep 14, 2023 · 0 comments
Open

Unstub in the then clause #618

nhorton opened this issue Sep 14, 2023 · 0 comments

Comments

@nhorton
Copy link

nhorton commented Sep 14, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants