带有 Rspec 测试的完整 rails json API 示例 [英] Complete rails json API example with Rspec tests
问题描述
我正在寻找实现 JSON API 并包含 RSpec 测试的 Rails 3 项目的一个很好的示例存储库.一个完整的教程会很棒,但我只接受一个评论良好的例子.
I'm looking for a good example repository of a Rails 3 project that implements a JSON API and has included RSpec tests. A full tutorial would be great but I'd settle for just a well commented example.
推荐答案
Yehuda Katz 和 Ryan Bigg 即将出版的优秀著作 Rails 3在行动中,有一章关于在贯穿整本书的示例应用程序之上构建测试驱动的 JSON API.
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.
虽然我强烈建议购买本书的测试版副本,但示例应用程序 Ticketee 的代码是开源的,可以在 GitHub.特别是,与 API 相关的所有内容都位于 /app/controllers/api
下,您可以在 /spec/api
中找到大量 RSpec 测试.
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
.
几个月前,当我不得不为 iPhone 应用程序编写 JSON 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.
这篇关于带有 Rspec 测试的完整 rails json API 示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!