filmov
tv
Rails 6 API Tutorial - RSpec API Tests POST/DELETE p.10
Показать описание
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.
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'
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'
Комментарии