RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Testing JSON APIs in Rails

https://minitestrails.com/guide/testing-api/

Chapter 16 of the free Minitest Rails guide is out now. Learn how to build a versioned API at /api/v1 and test full API:

  • Add versioned APIs under api/v1 from day one so clients get a stable version prefix.
  • TDD guest viewing first (index, show, quick filter, JSON media type), then login with Bearer token, revoke, and rate-limited sessions.
  • Wire Bearer auth on ApiController for authenticating APIs, then put those helpers on ApiTestCase for authenticating API tests.
  • TDD create (including nested records), update, and destroy.
  • Mirror existing share and export/download feature over the API.
  • Lastly, wrap up the tests by covering authorizations for guests and non-owners.
  • Try important API endpoints using CURL in the terminal for manual verification.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in