| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@eregon There are some modifications to mspec's raise_error to support matching causes, modifications to existing specs to use that functionality, and some additional cause-checking specs here, if you want to review. |
Sorry, something went wrong.
|
Failures appear to be GHA issues or bad timing in specs, unrelated to these changes. |
Sorry, something went wrong.
|
Thank you for adding more cause specs. My initial thought here is whether making raise_error more complicated for this is worth it: -> { 1 / 0 }.should raise_error(ZeroDivisionError, cause:)
# vs
-> { 1 / 0 }.should raise_error(ZeroDivisionError) { |e| e.cause.should == cause }It looks nice and it's expressive but OTOH it's not used in that many files. The main concern is MSpec tries to be as simple as possible so it can be used by early Ruby implementations. If you want to modify raise_error, could you make a PR https://github.com/ruby/mspec and add spec for it in https://github.com/ruby/mspec/blob/master/spec/matchers/raise_error_spec.rb? Or you could also do it in this PR and run the mspec specs locally. |
Sorry, something went wrong.
I think it will be used in many more as we continue to specify language-level exceptions that should have causes. I've only added a few cases here. And even without those additional cases, there were many places doing the block form of raise_error just to check causes. Those are almost all one-liners now. |
Sorry, something went wrong.
|
@eregon I cleaned up the commit that adds the cause: functionality, added specs for it, and updated others to support the expanded error output. Also fixed all style issues. |
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you, looks good, just needs a few more tweaks and it's good to go
Sorry, something went wrong.
This adds a cause kwarg to raise_error for matching the cause of a captured exception. The error output for failed cases is also modified to show both message and cause if they are being matched.
|
All requested changes have been made, merging. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Many places where we raise exceptions from JRuby core code, we do not attach $! as a cause. This leads to several issues, including part of the issue reported in #9398. This PR adds specs and fixes known cases.