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

Sdílet
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

Komentáře • 18

  • @lukapavicic7501
    @lukapavicic7501 Před 3 lety +1

    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.

  • @indrasusila00
    @indrasusila00 Před 4 měsíci

    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

    • @railspro
      @railspro  Před 4 měsíci

      Thank you for your kind words. I’m glad it helped!

  • @ahmedmustafa775
    @ahmedmustafa775 Před rokem +1

    Thanks man, this series helped me a lot ❤

  • @sharvyahmed
    @sharvyahmed Před 3 lety

    Thanks man, keep doing the great work.

  • @aknkrstozkn
    @aknkrstozkn Před 3 lety

    Good work sir, keep it up!

  • @procyu
    @procyu Před 3 lety

    Thank for the content! It helps a lot!

  • @marroquinyt
    @marroquinyt Před 3 lety

    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?

  • @ctrlaltcal
    @ctrlaltcal Před 11 měsíci

    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)

  • @2G1B
    @2G1B Před 3 lety

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

  • @rtfm-inc
    @rtfm-inc Před 3 lety

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

  • @amandatiemannjussianicioba333

    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

    • @amandatiemannjussianicioba333
      @amandatiemannjussianicioba333 Před 3 lety

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

  • @al-mokhtar_
    @al-mokhtar_ Před 2 lety

    thanks mate, can we see how to test jwt ?

    • @al-mokhtar_
      @al-mokhtar_ Před 2 lety

      @@railspro sorry just found it hhhh thanks a lot

  • @adrianoneynascimentodoamar7503

    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?

  • @vibhanshujain864
    @vibhanshujain864 Před 2 lety

    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.