Complete rails json API example with Rspec tests [closed] Complete rails json API example with Rspec tests [closed] ruby-on-rails ruby-on-rails

Complete rails json API example with Rspec tests [closed]


Yehuda Katz and Ryan Bigg's excellent upcoming book, Rails 3 in Action, has a chapter on building a test-driven JSON API on top of the example application that runs through the entire book.

While I strongly recommend buying a copy of the beta edition of the book, the code for the sample application, Ticketee, is open source and can be found on GitHub. In particular, everything API-related is namespaced under /app/controllers/api and you can find plenty of RSpec tests in /spec/api.

I was in your same position a couple of months ago when I was having to write a JSON API for an iPhone app so I'm well aware of the lack of good, test-driven, relevant tutorials online. Lucky for me I found out about the book and it turned out to be an absolute life saver.


RubyGems.org is open source and has a great example of an API


Can't necessarily answer the api example, but I can definitely vouch for the API testing of a rails 3 app in processes.

Here you go: whitneytaylorimura.wordpress.com

It has a full example using Cucumber, Rspec, & FactoryGirl to create your objects (with DatabaseCleaner to clean them up).