In this video series we will build a Rails API from scratch. Backend APIs are useful for serving data to frontend applications, mobile apps or other backend services.
✨ Check out the new version of this video series, which has been updated for Rails 7 • Rails 7 API Tutorial - Create project and ...
📖 You can also purchase the eBook and code for the new Rails 7 tutorial - https://tomkadwill.gumroad.com/l/rail...
This video covers:
00:30 - Wrap tests for each controller/action in their own 'describe' block
01:08 - Add a 'describe' block to test the create controller/action
02:25 - Add an 'it' block to test the creating a new book
02:30 - Make POST request with API params
03:56 - Add an assertion to check that response code is 201
04:31 - Add an assertion to check that a record was created in the database, using RSpec 'to change'
05:58 - Add a 'describe' and 'it' block to test the destroy controller/action
06:50 - Make DELETE request with record ID
07:10 - Add an assertion to check that response code is 204
07:26 - Add FactoryBot call so there is a database record to delete
08:31 - Remove hardcoded ID by assigning the FactoryBot record to a variable
09:20 - Improve the specs using RSpec let
10:31 - Add an assertion to check that a record was deleted from the database, using RSpec 'to change'
11:32 - Using RSpec let! to ensure database record is created before the test gets executed
12:18 - Refactoring test setup using 'before do'
If you’re new to this series, you may want to start with part 1: • Rails 6 API Tutorial - Create project and ...