Skip to content

Commit

Permalink
Raise an error if fetching a remote WSDL fails
Browse files Browse the repository at this point in the history
  • Loading branch information
joerixaop committed Jan 10, 2012
1 parent 91ff329 commit 4416df9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/savon/wasabi/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions spec/savon/wasabi/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4416df9

Please sign in to comment.