Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSpec - If I avoid using let, let and before, how to achieve same functionality?

Tags:

ruby

rspec

I have heard that it is a best practice to avoid its, let, let!, specify, before, and subject in RSpec.

In regards to let, let! and before, how can I perform setup tasks if not using these?

like image 532
Michael Durrant Avatar asked Nov 30 '22 20:11

Michael Durrant


1 Answers

Whoever wrote those best practices actually wants to just say "don't use RSpec". It's insane to avoid using core features and still think you can get things done well. Can you link to these best practices? I'd love to read them and see if they're justified or just some j-random-guy's opinion.

Avoid before and let? What? Really?

Avoid specify, I guess, it's just older syntax for it.

Avoid a specific subject call? I guess, if your code lives in an idealistic fantasy land. Strive to minimize it and use implicit subjects? Sure.

Avoid its? It's awesome! Why avoid it? Self-documenting one-line specs? How horrible.

like image 152
Nick Veys Avatar answered Dec 19 '22 05:12

Nick Veys