In , there are two different ways to write DRY tests, by using before or let. Their purpose is to create variables that are common across tests. In this post, we will explore differences between before and let and explain why let is preferred by the Ruby community.

let

let creates lazily-evaluated local variables. This means that let() is not evaluated until the method that it formed is run for the first time. It DRYs up the spec and makes it more readable.



Source link
thanks you RSS link
( https://dzone.com/articles/rspec-let-vs-before?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev)

LEAVE A REPLY

Please enter your comment!
Please enter your name here