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

Can't test against a class which extends Savon::Model #16

Open
davetapley opened this issue Jul 17, 2012 · 2 comments
Open

Can't test against a class which extends Savon::Model #16

davetapley opened this issue Jul 17, 2012 · 2 comments

Comments

@davetapley
Copy link

It appears that you can't test against a class which extends Savon::Model.

I have written savon_model_spec_fail.rb to demonstrate that instead of mocking the get_user SOAP action, the call is passed on to httpclient:

$ rspec savon_model_spec_fail.rb
.W, [2012-07-16T23:15:31.268851 #22655]  WARN -- : HTTPI executes HTTP GET using the httpclient adapter
FW, [2012-07-16T23:15:32.375432 #22655]  WARN -- : HTTPI executes HTTP GET using the httpclient adapter
F

Failures:

  1) with model mocks a SOAP request for an instance method
     Failure/Error: client.request(:get_user)
     SocketError:
       getaddrinfo: nodename nor servname provided, or not known (http://service.example.com:80)
     # ./savon_model_spec_fail.rb:32:in `get_user_class'
     # ./savon_model_spec_fail.rb:47:in `block (2 levels) in <top (required)>'

  2) with model mocks a SOAP request for an class method
     Failure/Error: client.request(:get_user)
     SocketError:
       getaddrinfo: nodename nor servname provided, or not known (http://service.example.com:80)
     # ./savon_model_spec_fail.rb:36:in `get_user_instance'
     # ./savon_model_spec_fail.rb:51:in `block (2 levels) in <top (required)>'

Finished in 1.19 seconds
3 examples, 2 failures

Failed examples:

rspec ./savon_model_spec_fail.rb:46 # with model mocks a SOAP request for an instance method
rspec ./savon_model_spec_fail.rb:50 # with model mocks a SOAP request for an class method
@timabdulla
Copy link
Member

I just ran this with a debugger. The problem is that Savon attempts to retrieve the WSDL document you specified. Since you specified a remote location for the document, it opens an HTTP connection to retrieve it. Of course the document does not actually exist, so your test fails.

[29, 38] in /Users/tim/.rvm/gems/ruby-1.9.3-p194/gems/savon-1.1.0/lib/savon/wasabi/document.rb
   29  
   30        # Resolves and returns the raw WSDL document.
   31        def resolve_document
   32          case document
   33            when /^http[s]?:/ then
=> 34              response = HTTPI.get(request)

@rubiii
Copy link
Contributor

rubiii commented Aug 10, 2012

that sounds about right. savon_spec stubs your soap requests, but if you depend on a remote wsdl,
savon still needs to fetch it to set up the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants