diff --git a/lib/evss/gi_bill_status/gi_bill_status_response.rb b/lib/evss/gi_bill_status/gi_bill_status_response.rb index 4033b64422d..32d3a9dc75a 100644 --- a/lib/evss/gi_bill_status/gi_bill_status_response.rb +++ b/lib/evss/gi_bill_status/gi_bill_status_response.rb @@ -126,6 +126,10 @@ def error_type 'unknown' end + def body + @response.body + end + private def timeout? diff --git a/spec/controllers/v0/post911_gi_bill_statuses_controller_spec.rb b/spec/controllers/v0/post911_gi_bill_statuses_controller_spec.rb index a8b67d8c2ff..3080634d30d 100644 --- a/spec/controllers/v0/post911_gi_bill_statuses_controller_spec.rb +++ b/spec/controllers/v0/post911_gi_bill_statuses_controller_spec.rb @@ -136,11 +136,16 @@ end it 'raises an InternalServerError including an exception with a detailed message' do - expect_block = expect do + response = instance_double(EVSS::GiBillStatus::GiBillStatusResponse) + allow(response).to receive(:error_type).and_return('unknown') + allow(response).to receive(:status).and_return(500) + allow(response).to receive(:body).and_return('Unknown error') + + expectation = expect do controller.send(:render_error_json, response) end - expect_block.to raise_error(Common::Exceptions::InternalServerError) do |error| + expectation.to raise_error(Common::Exceptions::InternalServerError) do |error| expected_msg = 'An unknown error occurred. Response error type: unknown, status: 500, body: Unknown error' expect(error.exception.message).to eq(expected_msg) end