What's the difference between RSpec's subject and let? When should they be used or not?

前端 未结 3 884
迷失自我
迷失自我 2020-12-22 17:04

http://betterspecs.org/#subject has some info about subject and let. However, I am still unclear on the difference between them. Furthermore, the S

3条回答
  •  心在旅途
    2020-12-22 17:55

    subject is what is under test, usually an instance or a class. let is for assigning variables in your tests, which are evaluated lazily vs. using instance variables. There are some nice examples in this thread.

    https://github.com/reachlocal/rspec-style-guide/issues/6

提交回复
热议问题