Permalink
Browse files

Merge branch 'remote_wsdl_check' of https://github.com/xaop/savon int…

…o xaop-remote_wsdl_check
  • Loading branch information...
2 parents 9e0db10 + 4416df9 commit 13031675138674c9961da251d572429c73d67ee4 @rubiii rubiii committed Feb 15, 2012
Showing with 20 additions and 1 deletion.
  1. +7 −1 lib/savon/wasabi/document.rb
  2. +13 −0 spec/savon/wasabi/document_spec.rb
@@ -30,7 +30,13 @@ def request
# Resolves and returns the raw WSDL document.
def resolve_document
case document
- when /^http[s]?:/ then HTTPI.get(request).body
+ when /^http[s]?:/ then
+ response = HTTPI.get(request)
+ if response.error?
+ raise Savon::HTTP::Error.new(response)
+ else
+ response.body
+ end
when /^</ then document
else File.read(document)
end
@@ -17,6 +17,19 @@
wsdl = Savon::Wasabi::Document.new("https://example.com?wsdl")
wsdl.xml.should == Fixture.wsdl(:authentication)
end
+
+ end
+
+ context "with an inaccessible remote document" do
+ before do
+ response = HTTPI::Response.new 401, {}, Fixture.wsdl(:authentication)
+ HTTPI.stubs(:get).returns(response)
+ end
+
+ it "should raise an error when authentication fails" do
+ wsdl = Savon::Wasabi::Document.new("http://example.com?wsdl")
+ expect { wsdl.xml }.to raise_error(Savon::HTTP::Error)
+ end
end
context "with a local document" do

0 comments on commit 1303167

Please sign in to comment.