From 136383857df2adccdeb672545b0c04fb1210a529 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Wed, 15 Mar 2017 07:50:56 -0600 Subject: [PATCH] Spec for handling unexpected errors --- spec/netsuite/utilities_spec.rb | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/spec/netsuite/utilities_spec.rb b/spec/netsuite/utilities_spec.rb index f77581bdb..512ff54b0 100644 --- a/spec/netsuite/utilities_spec.rb +++ b/spec/netsuite/utilities_spec.rb @@ -32,6 +32,67 @@ expect(NetSuite::Records::Account).to have_received(:get).exactly(1).times end + + it 'works when an unexpected error occurs' do + xml_msg = < + + + WEBSERVICES_TSTDRV1022750_103020151182829907744988579_5d1f6b + + + + + + + + UNEXPECTED_ERROR + An unexpected error occurred. Error ID: igduqcc81p7jpm8fklupr + + + + + + + +EOL + xml_msg = < + + + soapenv:Server.userException + An unexpected error occurred + + partners-java10006.bos.netledger.com + + + +EOL + + # + # + # + # soapenv:Server.userException + # You do not have permission to access web services feature. + # + # + # UNEXPECTED_ERROR + # An unexpected error occurred. Error ID: j0b0mmf81qhk9h7ezjgbz + # + # partners-java10001.bos.netledger.com + # + # + # + # + + ns_account_id = 123 + + exception = Savon::SOAPFault.new(OpenStruct.new(body: xml_msg), Nori.new({}), xml_msg) + + allow(NetSuite::Records::Account).to receive(:get).and_raise(exception) + + NetSuite::Utilities.get_record(NetSuite::Records::Account, ns_account_id) + end end it 'pulls a record by internal id' do