How to Spec a Web Services Client


#1

I put a pastie out at http://pastie.org/444424, which is an
implementation (short) of an XML-RPC client. I’m getting wrapped
around an axle trying to figure out how to spec this without actually
hitting the remote server.

Is the best way to do this stubbing out the xml-rpc :call method to
return known good or bad results to get the network out of the mix?
Any thoughts are much appreciated!

Thanks.


#2

On Sun, Apr 12, 2009 at 3:24 PM, s.ross removed_email_address@domain.invalid wrote:

I put a pastie out at http://pastie.org/444424, which is an implementation
(short) of an XML-RPC client. I’m getting wrapped around an axle trying to
figure out how to spec this without actually hitting the remote server.

I just had the same challenge with a SOAP client I’m building that
hits a fairly complicated service. My solution was to generate a
dummy SOAP server that accepts the right calls and returns the right
kinds of dummy answers. Since I used the wsdl2ruby script (part of
the soap4r gem) to create a client skeleton from the WSDL file,
creating a server skeleton was just another command line. I added a
few lines to spec_helper.rb to start the server and override the
client code’s service URL, and now I just fill out the return values
from the server methods as part of writing my specs for each feature.


Have Fun,
Steve E. (removed_email_address@domain.invalid)
ESCAPE POD - The Science Fiction Podcast Magazine
http://www.escapepod.org


#3

On Sun, Apr 12, 2009 at 4:03 PM, Stephen E. removed_email_address@domain.invalid wrote:

I just had the same challenge with a SOAP client I’m building that
hits a fairly complicated service. My solution was to generate a
dummy SOAP server that accepts the right calls and returns the right
kinds of dummy answers.

Oh – I forgot to mention. I haven’t done this yet, but part of my
plan is also to build a switch into my Cucumber env.rb file so that I
can flip between using my dummy server and the real remote Web service
for feature runs. Hitting their API constantly with tests during my
development cycle is an unfriendly act, but if I never run my
integration tests against it at all, I’m not proving what actually
matters.


Have Fun,
Steve E. (removed_email_address@domain.invalid)
ESCAPE POD - The Science Fiction Podcast Magazine
http://www.escapepod.org


#4

Thanks. I think instead of a server, I’ll need to dive into replacing
the results of XmlRpc::Client#call unless there’s some ultra-cool way
I haven’t thought of.

Steve