Mocking restful services

172 views
Skip to first unread message

Carlos Eberhardt

unread,
Mar 2, 2012, 8:40:00 AM3/2/12
to api-...@googlegroups.com
A bit off the topic of design, hope nobody minds. Would anyone share the tools/techniques they've found most successful for mocking restful services? 

Thanks!
Carlos

Sam Ramji

unread,
Mar 2, 2012, 1:53:48 PM3/2/12
to api-...@googlegroups.com
I find a good sense of humor usually helps.

But seriously, both Sinatra and Grape have been discussed as good prototyping environments as well as Visual Studio with the new WCF-REST component.

Sam
--
Cheers,

Sam

Sam Ramji | Strategy | Apigee | @sramji | +1-510-913-6495

Carlos Eberhardt

unread,
Mar 3, 2012, 9:47:50 AM3/3/12
to api-...@googlegroups.com
Thanks, Sam. :) Reminded me of this: https://twitter.com/#!/iamaaronheld/status/175251863602593792

I might give webmachine a shot: http://wiki.basho.com/Webmachine.html

-Carlos

landlessness

unread,
Mar 3, 2012, 10:16:17 AM3/3/12
to api-...@googlegroups.com
Timely.

Last weekend I built a prototype of a service with about a dozen objects and as many associations. I was able to cover a good size surface area quickly using nifty:scaffold in Rails.

This weekend (as soon as I pull myself out of bed today) I'm going to (as Sam pointed out) use Grape to create the versioned API facade in front of it hoping that Rack lets me connect to the Rails all as easily as promised.

My goal is to have a robust mock that supports reads n writes in just 20 or so boy-hours of work.

The final step will be setting up the OAuth provider.

I'll write something up about the experience once I get thru it all.

Roy Wilson

unread,
Mar 3, 2012, 10:22:25 AM3/3/12
to api-...@googlegroups.com
Landless, I look forward to seeing what you discover.
--
Roy Wilson
email: anw...@gmail.com




Andrew Kuklewicz

unread,
Mar 3, 2012, 4:41:25 PM3/3/12
to api-...@googlegroups.com
For rails, I am using FakeWeb for mocking - 


Grape is interesting for having such a simple (sinatra-like) way to create the API, and I definitely agree in have some different layer or controllers for your API in Rails instead of overloading the view controllers.

As I recall, Grape has no particularly helpful addition to how you handle the serialization of the objects.  I needed finer grain control of what gets included and excluded, and so ended up using roar (https://github.com/apotonick/roar), which has the interesting benefit of letting you define representers that can be used on client and serverside to, uh, represent the models and handle serialization/deserialization. YMMV, but it has worked well for me so far.

I also have this hooked up with OAuth2 for the API methods using pelle's oauth-plugin and the oauth2 gem, and written a simple client gem for the API using oauth2 and roar.

Andrew Kuklewicz
Reply all
Reply to author
Forward
0 new messages