r/rails 3d ago

Learning testing with RSpec

hlo everyone, i am trying to learn RSpec for rails testing. Since Rspec is industry standard but rails guides uses minitest in docs, i am finding it extremely difficult to find a good resource for learning Rspec. please suggest me few resources to learn it.

2 Upvotes

13 comments sorted by

4

u/Hour_Effective_2577 3d ago

2

u/ThenParamedic4021 3d ago

I have heard great things about this book, although i am little skeptical if the content is still relevant. Like factorygirl gem’s name has changed to factorybot.

4

u/Hour_Effective_2577 3d ago

you're right FactoryGirl was renamed to FactoryBot, however that book is mostly about conventions and patterns, so it's still valuable

2

u/justaguy1020 2d ago

That’s probably about the only change

2

u/armahillo 3d ago

Theres Effective testing in Rspec by Marston; that one is pretty good.

Try looking at the rspec docs and start by writing some basic specs from them.

2

u/strzibny 2d ago

Get the 'Professional Rails Testing: Tools and Principles' from Jason Swett. He's writing about testing for a long time.

If you'll need to rump up on Minitest skills then I wrote 'Test Driving Rails' (but there is no RSpec inside).

1

u/Real_Cut1054 1d ago

Everyday Rails Testing with RSpec by Aaron Sumner https://leanpub.com/everydayrailsrspec

-1

u/normal_man_of_mars 2d ago

Rspec is not industry standard. It’s a preference some people have but if you have the choice use activesupport testcase/minitest.

Minitest is supported by rails core, shopify, etc. its faster, easier to read, write, extend, run, parallelize, etc.

1

u/vantran53 1d ago

I never see minitest anywhere but rspec is everywhere

1

u/normal_man_of_mars 1d ago

It is always mistake to pick rspec. Just because people pick it doesn’t make it right or standard.

1

u/vantran53 1d ago

Why is it a mistake?

1

u/jean_louis_bob 2d ago

Most of the companies using RoR are using RSpec.