In RSpec, 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 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.
thanks you RSS link