Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise an error if fetching a remote WSDL fails #255

Merged
merged 1 commit into from
Feb 15, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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