testdouble / suture

🏥 A Ruby gem that helps you refactor your legacy code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support permitted error types

searls opened this issue · comments

Some code raises error intentionally for certain inputs and is the effective "return" value of a given call.

  • Suture config should take a list of expected error types:
  Suture.create(:foo, {
    :old => ->{ raise MyErrorClass.new },
    :args => [],
    :expected_errors => [MyErrorClass, MyOtherError]
  })
  • When recording the above, the "result" should be the error
  • When verifying the above, if an error is rescued, check to see if it was expected and if it matches a permitted error type. Only mark the test result in error if it was not permitted.