You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although we suggest using let_it_be instead of let!, there is one important difference: you can override let! definition with the same or nested context, so only the latter one is called; let_it_be records could be overridden, but still created. For example:
context"A"dolet!(:user){create(:user,name: "a")}let_it_be(:post){create(:post,title: "A")}specify{expect(User.all.pluck(:name)).toeq["a"]}specify{expect(Post.all.pluck(:title)).toeq["A"]}context"B"dolet!(:user){create(:user,name: "b")}let_it_be(:post){create(:post,title: "B")}specify{expect(User.all.pluck(:name)).toeq["b"]}specify{expect(Post.all.pluck(:title)).toeq["B"]}# fails, because there are two postsendend
The situation becomes even more trickier when you have multiple let_it_be records and dependencies between them.
TODO
Add a configuration option to warn or raise an exception whenever a let_it_be definition is redefined:
Context
Although we suggest using
let_it_be
instead oflet!
, there is one important difference: you can overridelet!
definition with the same or nested context, so only the latter one is called;let_it_be
records could be overridden, but still created. For example:The situation becomes even more trickier when you have multiple let_it_be records and dependencies between them.
TODO
Add a configuration option to warn or raise an exception whenever a let_it_be definition is redefined:
The text was updated successfully, but these errors were encountered: