Forum: RSpec How to Spec a Web Services Client

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2009-04-12 21:27
(Received via mailing list)
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.
994e42bda994be2cd1d791f18ee6d561?d=identicon&s=25 Stephen Eley (Guest)
on 2009-04-12 22:10
(Received via mailing list)
On Sun, Apr 12, 2009 at 3:24 PM, s.ross <cwdinfo@gmail.com> 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 Eley (sfeley@gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
994e42bda994be2cd1d791f18ee6d561?d=identicon&s=25 Stephen Eley (Guest)
on 2009-04-12 22:25
(Received via mailing list)
On Sun, Apr 12, 2009 at 4:03 PM, Stephen Eley <sfeley@gmail.com> 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 Eley (sfeley@gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2009-04-12 22:47
(Received via mailing list)
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
This topic is locked and can not be replied to.