Search code examples
ruby-on-railsrestcontinuous-integrationintegration-testingacceptance-testing

Rails Rest API External Testing


I am building a REST Web Service layer on top of a Rails app that will be used by an Iphone application. The response format is XML.

I would like to build some acceptance tests that should be external to the rails stack (and should test everything, including the http server). The test scenarios are quite complex, involving the process of searching/posting/reviewing an order. What would be the best solution to accomplish this?

a. Ruby script using curl/curb to fetch the request and Hpricot to parse the request

b. Selenium

c. ..

It would also be nice that those tests could be used as integration tests (therefore, run on every git commit). What integration solution would you recommend?

a. Integrity

b. CruiseControl

c. something else


Solution

  • I've used three approaches over this last few years

    Active-resource

    I found this to be too concerned with looking like active-record to be a great solution. In some cases I had to patch parts of it to work as I'd like a REST client to behave.


    Rest-client

    This gem is very good - well documented and does works as expected. I combined this with my own simple DSL and it's worked out better than a generic testing framework


    XML over HTTP

    I use this for performance testing. Very flexible but the learning curve is higher than Rest-client. If you go down this approach you could use the Net::HTTP core class or the HTTParty gem (I haven't tried this but it looks great>

    A really good resource is this Net::HTTP cheat-sheet


    For ad-hoc testing I've also found the Rest Client add-in for Firefox very useful.