views:

2066

answers:

4

I want to test the REST api on my Rails site. What is the easiest/best way to do this with the rails testing framework? I'm only doing the standard resourceful stuff, so I am wondering in particular, since this is so bog standard, if there is any automagical way to test this stuff.

A: 

If you are looking at testing the APIs that you have created manually - you may want to try this! Seems to work well!

REST Client - Simply Test REST APIs

You cannot do the automated testing with this though!

That's not really REST if the URIs are available as part of the API. There can only be the entry-point URI in a RESTful API.
Wahnfrieden
+2  A: 

I would recommend using Cucumber. Cucumber emulates a browser and you can verify the results it gets. This works fine for XML requests as well as JSON and plain old HTML.

Ariejan
+2  A: 

This is not automated but it is really great for seeing what your API is doing.

http://hurl.r09.railsrumble.com/

jluebbert
A: 

We use RESTClient a Firefox add-on to visit and test REST services.

https://addons.mozilla.org/en-US/firefox/addon/9780

We have been using this in my team for a couple of months and I don't think we could do our work without it. It's very easy to get up and running and friendly to use.

If you get the latest version from Sourceforge there is even Oauth Support for it, something I haven't found in any other REST client.

http://sourceforge.net/projects/restclient/develop

One, of many, advantages of using a Firefox add-on is that it's cross plattform. We use the same tool (RESTclient) for all members of our team even though we use different OS's (Mac, Linux, Windows).

Jonas Söderström