Rails 6 API Tutorial - API Tests with RSpec p.9
Vložit
- čas přidán 2. 06. 2024
- 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 -...
📖 You can also purchase the eBook and code for the new Rails 7 tutorial - tomkadwill.gumroad.com/l/rail...
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
If you’re new to this series, you may want to start with part 1: • Rails 6 API Tutorial -... - Věda a technologie
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.
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
Thank you for your kind words. I’m glad it helped!
Thanks man, this series helped me a lot ❤
Thanks man, keep doing the great work.
Good work sir, keep it up!
Thank for the content! It helps a lot!
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?
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)
Really good tutorial man! I just subscribed to your channel. Hope to see some more in-depth rails testing tutorials. Thanks!
rspec did not work for me originally, but gave me a suggestion: sudo apt install ruby-rspec-core - did that and it worked.
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
@@railspro Hey Tom, thank you so much for your answer. I ended up having problems with my rbenv. But is all working now. Thanks again for your help. Cheers
thanks mate, can we see how to test jwt ?
@@railspro sorry just found it hhhh thanks a lot
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?
@@railspro
I sent it now, thank you so much.
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.