Skip to content

Commit

Permalink
Fix problem with SoapFault if tag name is ServiceFault
Browse files Browse the repository at this point in the history
  • Loading branch information
nathansamson authored and tjarratt committed Jan 30, 2015
1 parent 64b8376 commit 680b240
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ gem "simplecov", :require => false
gem "coveralls", :require => false
gem "uuid"

gem 'json'

platform :rbx do
gem 'json'
gem 'racc'
Expand Down
3 changes: 2 additions & 1 deletion lib/savon/soap_fault.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(http, nori, xml = nil)
attr_reader :http, :nori, :xml

def to_s
fault = nori.find(to_hash, 'Fault')
fault = nori.find(to_hash, 'Fault') || nori.find(to_hash, 'ServiceFault')
message_by_version(fault)
end

Expand All @@ -33,6 +33,7 @@ def to_hash
private

def message_by_version(fault)
puts fault
if nori.find(fault, 'faultcode')
code = nori.find(fault, 'faultcode')
text = nori.find(fault, 'faultstring')
Expand Down
5 changes: 5 additions & 0 deletions spec/savon/soap_fault_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
describe Savon::SOAPFault do
let(:soap_fault) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault)), nori }
let(:soap_fault2) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault12)), nori }
let(:soap_fault_funky) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault_funky)), nori }
let(:soap_fault_nc) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault)), nori_no_convert }
let(:soap_fault_nc2) { Savon::SOAPFault.new new_response(:body => Fixture.response(:soap_fault12)), nori_no_convert }
let(:another_soap_fault) { Savon::SOAPFault.new new_response(:body => Fixture.response(:another_soap_fault)), nori }
Expand Down Expand Up @@ -63,6 +64,10 @@
it "works even if the keys are different in a SOAP 1.2 fault message" do
expect(soap_fault_nc2.send method).to eq("(soap:Sender) Sender Timeout")
end

it "works even if the keys are different in a funky SOAP fault message" do
expect(soap_fault_funky.send method).to eq("(42) The Answer to Life The Universe And Everything")
end
end
end

Expand Down

0 comments on commit 680b240

Please sign in to comment.