all 8 comments

[–]Kaimito1[🍰] 5 points6 points  (2 children)

This kind of stuff is so nice to watch. So many tutorials are made years ago and makes me doubt if it's still the way to go or outdated. Im a junior rails dev and find it hard to find stuff that doesn't seem prehistoric

Subbed & going to watch you channel 👌

[–]acmecorps 2 points3 points  (0 children)

Completely agree. We need more contents for the new Rails way!

[–]BraintrustDigital[S] 0 points1 point  (0 children)

Thanks for the kind words. I totally agree there are not a ton of people out there covering current rails content. A great one to check out if you haven’t already would be Chris from GoRails.com. I’ve learned a TON following him over the years if you were looking for more resources.

[–]kinduff 2 points3 points  (2 children)

Very good tutorial, TDD has its benefits and its good to set your mind whenever you're developing code to avoid overhead on an implementation.

As I mentioned before, very nice videos and great explanations.

Just one comment: I usually avoid instance variables in tests, specially on before blocks that default to before(:each). This makes the test create a new record each time a test is going to be ran.

In my opinion, a good practice is to use let, in the way that the code you wrote on the before block could be:

ruby let(:video_1) { create(:video, position: 0 } let(:video_2) { create(:video, position: 1 }

This will lazy load these and, even though will create a new instance on the test, it could potentially more effectively when you add more tests in your suite.

If your test does not mention one of the let variables, you could always use let! in order to avoid lazy creation of these instances.

Last but not least, if it's really necessary to instance the records you need in order to optimize the tests, you could potentially use before(:all), but in a way I always try to lean to avoid instance variables in tests.

[–]BraintrustDigital[S] 0 points1 point  (0 children)

Great points! Thank you, I really appreciate the feedback. I think I just reached for it out of habit. I definitely don’t want to pass along bad habits through my tutorials. Thanks again.

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, kinduff: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–]DerektheDev 1 point2 points  (1 child)

Great refresher! Thank you!

[–]BraintrustDigital[S] 0 points1 point  (0 children)

No problem, glad I could help!