spec/savon/soap_fault_spec.rb in savon-2.1.0 vs spec/savon/soap_fault_spec.rb in savon-2.2.0
- old
+ new
@@ -1,14 +1,17 @@
require "spec_helper"
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_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 }
let(:no_fault) { Savon::SOAPFault.new new_response, nori }
let(:nori) { Nori.new(:strip_namespaces => true, :convert_tags_to => lambda { |tag| tag.snakecase.to_sym }) }
+ let(:nori_no_convert) { Nori.new(:strip_namespaces => true, :convert_tags_to => nil) }
it "inherits from Savon::Error" do
expect(Savon::SOAPFault.ancestors).to include(Savon::Error)
end
@@ -50,10 +53,18 @@
end
it "returns a SOAP fault message (with different namespaces)" do
expect(another_soap_fault.send method).to eq("(ERR_NO_SESSION) Wrong session message")
end
+
+ it "works even if the keys are different in a SOAP 1.1 fault message" do
+ expect(soap_fault_nc.send method).to eq("(soap:Server) Fault occurred while processing.")
+ end
+
+ 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
end
end
describe "#to_hash" do
it "returns the SOAP response as a Hash unless a SOAP fault is present" do
@@ -79,9 +90,30 @@
:code => { :value => "soap:Sender", :subcode => { :value => "m:MessageTimeout" } }
}
}
expect(soap_fault2.to_hash).to eq(expected)
+ end
+
+ it "works even if the keys are different" do
+ expected = {
+ "Fault" => {
+ "Code" => {
+ "Value" => "soap:Sender",
+ "Subcode"=> {
+ "Value" => "m:MessageTimeout"
+ }
+ },
+ "Reason" => {
+ "Text" => "Sender Timeout"
+ },
+ "Detail" => {
+ "MaxTime" => "P5M"
+ }
+ }
+ }
+
+ expect(soap_fault_nc2.to_hash).to eq(expected)
end
end
def new_response(options = {})
defaults = { :code => 500, :headers => {}, :body => Fixture.response(:authentication) }