Basic rspec Ruby on Rails model specs

Sdílet
Vložit
  • čas přidán 11. 07. 2021
  • In this episode you'll learn some basics for testing simple methods on Ruby on Rails models.
    #rails #rubyonrails
  • Jak na to + styl

Komentáře • 15

  • @tomdringer985
    @tomdringer985 Před 5 měsíci

    Really enjoying these testing videos. ?You make it all crystal clear. Thank you!

  • @lucinejaff7376
    @lucinejaff7376 Před 9 měsíci

    Great tutorial! Thank you so much.

  • @viveknaik6798
    @viveknaik6798 Před rokem +1

    Extremely well done! I watch with 75% speed.

  • @martinkarkovich3037
    @martinkarkovich3037 Před 2 lety +3

    very detailed explanations!

  • @CHACHANUS
    @CHACHANUS Před 2 lety +3

    great video !!!! in the next video for complex tests can you show examples how i can refactor long tests , and , if is possible create a function or method when i have to build factories with same format, example form4=build.... and these lines are repeated along my tests? . would be nice if teach us some about code coverage with simplecov... thanks in advance,,, channels like yours keep Rails alive.

  • @john.dough.
    @john.dough. Před rokem

    awesome! Thanks for sharing

  • @farsiteguide2735
    @farsiteguide2735 Před 5 měsíci

    Tnx for tutorials, but where can I find form4tracker build videos?

  • @judisjeevan4908
    @judisjeevan4908 Před rokem

    Hi CJ. Which Vim theme are you using? Also which terminal? Whether it is iTerm or Terminal in mac?

    • @cjav_dev
      @cjav_dev  Před rokem

      One dark is the theme in iTerm. I also set some custom colors on iTerm

  • @mutebiugofficial8827
    @mutebiugofficial8827 Před rokem

    How can I test for regular expressions with rspec and shoulda matchers.

  • @dbsmith3974
    @dbsmith3974 Před 2 lety +1

    is the schema information automatically added to your model file or do you manually add that information?

    • @cjav_dev
      @cjav_dev  Před 2 lety +1

      When you create the model and a migration, and run the migrations, the schema is automatically updated. This is a solid question and something I totally glossed over. Will try to cover this better in the future.

    • @dbsmith3974
      @dbsmith3974 Před 2 lety

      @@cjav_dev Im familiar with the schema being created, but Ive never come across the table details in the model like you have here. I even ran a rails g rspec:mode dummy name born_at:integer to see if it was something I may have missed but nothing was there

    • @cjav_dev
      @cjav_dev  Před 2 lety +1

      oh! so if you run `rails g rspec:model Dummy` that'll create the spec file and the factory, but both will be empty, even if the schema has columns. If you run `rails g rspec:model Dummy born_at:integer` that should create the same spec file, but the factory should have a new born_at thing setup for you.
      In practice, when you generate new models like: `rails g model Dummy born_at:datetime` that'll generate the model, migration, spec, and it'll also add born_at to your factory, which is super handy :)

    • @kang_marvin
      @kang_marvin Před rokem

      It's a gem called Annotate.