Guest User

Untitled

a guest
Jun 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <pre>
  2. Factory.define :valid_thing, :class => Thing do |t|
  3. t.name 'Some valid thing'
  4. t.user { Factory(:valid_user) }
  5. end
  6. </pre>
  7.  
  8. <pre>
  9. Wrapping the call in {} causes Factory Girl to not evaluate the code inside of the
  10. braces until the :valid_thing factory is created. This will force it to wait until the
  11. :valid_user factory has been loaded (Your example is failing because it is not yet
  12. loaded), it will also cause a new :valid_user to be created for each :valid_thing
  13. rather than having the same user for all :valid_thing's (Which is probably what you
  14. want).
  15. </pre>
Add Comment
Please, Sign In to add comment