Skip to content

Instantly share code, notes, and snippets.

@david-shockley-beeline
Created April 11, 2018 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david-shockley-beeline/008ea9122e62b051b3614d07a36fae23 to your computer and use it in GitHub Desktop.
Save david-shockley-beeline/008ea9122e62b051b3614d07a36fae23 to your computer and use it in GitHub Desktop.
stub_const('Something', object_double(Something))
unrenderable_exception = instance_double(Exception)
allow(unrenderable_exception).to receive(:my_custom_method_ive_added_to_exception).and_raise
allow(Something).to receive(:some_method).and_raise(unrenderable_exception)
# code that triggers the call to Something.some_method
# assertions that check for the result
# Essentially I have some custom exception handling logic in my_custom_method_ive_added_to_exception
# and want to test that if it goes wrong my 'fallback' exception handling kicks in.
# Unfortunately, the above doesn't seem to work. Instead of using my 'unrenderable_exception' mock object,
# I see a RuntimeError as the raised exception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment