spec: include error report details on failed API specs

Change-Id: I7c3296c73eb7e0f2b8622bd32e1c122340f9c991
Reviewed-on: https://gerrit.instructure.com/72144
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2016-02-12 10:20:27 -07:00
parent 9b49f1aa16
commit c2e5327da1
1 changed files with 16 additions and 1 deletions

View File

@ -53,7 +53,22 @@ def api_call(method, path, params, body_params = {}, headers = {}, opts = {})
if opts[:expected_status]
assert_status(opts[:expected_status])
else
expect(response).to be_success, response.body
unless response.success?
error_message = response.body
begin
json = JSON.parse(response.body)
error_report_id = json['error_report_id']
error_report = ErrorReport.find_by(id: error_report_id) if error_report_id
if error_report
error_message << "\n"
error_message << error_report.message
error_message << "\n"
error_message << error_report.backtrace
end
rescue JSON::ParserError
end
end
expect(response).to be_success, error_message
end
if response.headers['Link']