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 8b5487671db..70b904c175c 100644 --- a/lib/evss/gi_bill_status/gi_bill_status_response.rb +++ b/lib/evss/gi_bill_status/gi_bill_status_response.rb @@ -113,6 +113,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..7641f9f356b 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,14 @@ 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") + + expect do controller.send(:render_error_json, response) - end - - expect_block.to raise_error(Common::Exceptions::InternalServerError) do |error| + end.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