Home When to use RSpec let()?
Reply: 0

When to use RSpec let()?

user521 Published in June 23, 2018, 4:31 am

I tend to use before blocks to set instance variables. I then use those variables across my examples. I recently came upon let(). According to RSpec docs, it is used to

... to define a memoized helper method. The value will be cached across multiple calls in the same example but not across examples.

How is this different from using instance variables in before blocks? And also when should you use let() vs before()?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.395896 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO