Rails 6 API Tutorial - API Tests with RSpec p.9

preview_player
Показать описание
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:
0:09 - Why automated test is important and useful
0:41 - Using RSpec as a test framework
1:16 - Installing the RSpec gem
2:02 - Running RSpec via the command line
2:13 - Initializing the RSpec directory and test helpers
2:49 - Creating the first API request spec to test for a success status code
5:33 - Updating the test with an assertion for the response body
6:45 - Creating mock test data using FactoryBot

Рекомендации по теме
Комментарии
Автор

amazing tutorial series, t's still relevant on rails 7.
to be honnest, i just learn ROR just on 2 days. thanks, & blassed for you sir

indrasusila
Автор

Great approach to teaching Rails! I really like how you debug your errors in the video and show the real problems programmers face while developing and not just working by some script on your second monitor.

lukapavicic
Автор

Thanks man, this series helped me a lot ❤

ahmedmustafa
Автор

Thanks man, keep doing the great work.

sharvyahmed
Автор

Thank for the content! It helps a lot!

procyu
Автор

Really good tutorial man! I just subscribed to your channel. Hope to see some more in-depth rails testing tutorials. Thanks!

GB
Автор

Great video! I have a question about testing routes that require authentication. Lests imagine I have a route to return user information, but that routes requires the user to be authenticated with a JWT. How should I test that route?

marroquinyt
Автор

This is great thank you, I'm just a little confused as to how the FactoryBot creates a book when we have not explicitly told the factory that is creates Books (as in the model)

ctrlaltcal
Автор

rspec did not work for me originally, but gave me a suggestion: sudo apt install ruby-rspec-core - did that and it worked.

rtfm-inc
Автор

Would you know if Rspec_rails would work on ruby 2.7. I am new at testing and when I run rspec command I get this message: ✗ rspec
rbenv: rspec: command not found

The `rspec' command exists in these Ruby versions:
2.6.6

Thank you for your video, your explanations are most helpful

amandatiemannjussianicioba
Автор

thanks mate, can we see how to test jwt ?

al-mokhtar_
Автор

Very good video!! Congratulations! I am looking to test request with authentication. I've looked on several sites but every way I try, it goes wrong! I am using the device and simple_token_authentication 1.0 gem for authentication, ruby 2.7.2, rails 6.0.3 and rspec 4.0.0. Can you help me?

adrianoneynascimentodoamar
Автор

For me generate commands give me usage can someone suggest:
rails generate rspec:install
Usage:
rails new APP_PATH [options]

.
.
.

Example:
rails new ~/Code/Ruby/weblog

This generates a skeletal Rails installation in ~/Code/Ruby/weblog.

vibhanshujain