diff --git a/lib/wasabi.rb b/lib/wasabi.rb index 2f27130..9e338eb 100644 --- a/lib/wasabi.rb +++ b/lib/wasabi.rb @@ -13,8 +13,8 @@ class Wasabi SOAP_1_1 = 'http://schemas.xmlsoap.org/wsdl/soap/' SOAP_1_2 = 'http://schemas.xmlsoap.org/wsdl/soap12/' - def initialize(wsdl, request = nil) - resolver = Resolver.new(request) + def initialize(wsdl, http = nil) + resolver = Resolver.new(http) importer = Importer.new(resolver, self) @documents, @schemas = importer.import(wsdl) diff --git a/lib/wasabi/errors.rb b/lib/wasabi/errors.rb index 5ae3b2b..d662db9 100644 --- a/lib/wasabi/errors.rb +++ b/lib/wasabi/errors.rb @@ -2,15 +2,4 @@ class Wasabi Error = Class.new(StandardError) - HTTPError = Class.new(Error) do - - def initialize(message, response = nil) - super(message) - @response = response - end - - attr_reader :response - - end - end diff --git a/lib/wasabi/resolver.rb b/lib/wasabi/resolver.rb index cfe994c..f44edad 100644 --- a/lib/wasabi/resolver.rb +++ b/lib/wasabi/resolver.rb @@ -1,13 +1,11 @@ -require 'httpi' - class Wasabi class Resolver URL_PATTERN = /^http[s]?:/ XML_PATTERN = /^") - xml.should == "" - end - - it "raises HTTPError when #load_from_remote gets a response error" do - code = 404 - headers = { - "content-type" => "text/html" - } - body = "404 Not FoundOops!" - - failed_response = HTTPI::Response.new(code, headers, body) - HTTPI.stubs(:get).returns(failed_response) - - expect { Wasabi::Resolver.new.resolve("http://example.com?wsdl") }.to raise_error { |error| - error.should be_a(Wasabi::Resolver::HTTPError) - error.message.should == "Error: #{code}" - error.response.should == failed_response - } - end + subject(:resolver) { Wasabi::Resolver.new(http_test_client) } + + let(:http_test_client) { + Class.new { + + def get(url) + "raw_response for #{url}" + end + + }.new + } + + it 'resolves remote files using a simple HTTP client interface' do + url = 'http://example.com?wsdl' + + xml = resolver.resolve(url) + expect(xml).to eq("raw_response for #{url}") + end + + it 'resolves local files' do + fixture = fixture(:authentication) + + xml = resolver.resolve(fixture.path) + expect(xml).to eq(fixture.read) + end + + it 'simply returns any raw input' do + string = '' + + xml = resolver.resolve(string) + expect(xml).to eq(string) end end diff --git a/wasabi.gemspec b/wasabi.gemspec index 1999a29..e9e9c0a 100644 --- a/wasabi.gemspec +++ b/wasabi.gemspec @@ -13,8 +13,7 @@ Gem::Specification.new do |s| s.rubyforge_project = s.name - s.add_dependency "httpi", "~> 2.0" - s.add_dependency "nokogiri", ">= 1.4.0" + s.add_dependency "nokogiri", ">= 1.4" s.add_development_dependency "rake", "~> 10.0" s.add_development_dependency "rspec", "~> 2.13"