Rails 6 API Tutorial - RSpec API Tests POST/DELETE p.10

Veröffentlicht am: 06 September 2020
auf dem Kanal: Rails Pro
8,653
181

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 ...  


Auf dieser Seite können Sie das Online-Video Rails 6 API Tutorial - RSpec API Tests POST/DELETE p.10 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Rails Pro 06 September 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 8,653 Mal angesehen und es wurde von 181 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!