DEV: Catch Mocha::ExpectationError in request specs (#14897)

Same issue as 28b00dc6fc, the
Mocha::ExpectationError inherits from Exception instead
of StandardError so RspecErrorTracker does not show the
actual failed expectation in request specs, the status of
the response is just 500 with no further detail.
This commit is contained in:
Martin Brennan 2021-11-12 13:10:16 +10:00 committed by GitHub
parent 2371da9f25
commit e0be6ce1ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,9 +46,9 @@ class RspecErrorTracker
@app.call(env)
# This is a little repetitive, but since WebMock::NetConnectNotAllowedError
# inherits from Exception instead of StandardError it does not get captured
# by the rescue => e shorthand :(
rescue WebMock::NetConnectNotAllowedError, StandardError => e
# and also Mocha::ExpectationError inherit from Exception instead of StandardError
# they do not get captured by the rescue => e shorthand :(
rescue WebMock::NetConnectNotAllowedError, Mocha::ExpectationError, StandardError => e
RspecErrorTracker.last_exception = e
raise e
end