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/v1from 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