1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
Commit graph

7 commits

Author SHA1 Message Date
Joshua Clayton
8012d3d81b Dynamic attributes referencing dynamic attributes of child factories work correctly
Fixes #173
2011-08-08 23:46:34 -04:00
Thomas Walpole
2ccbf4561b Non-overriden parent dynamic methods should be assigned before the child's
Closes #173
2011-08-08 22:32:24 -04:00
Flavio Castelli
28f541eefc Ensure static attributes are executed before dynamic ones.
Static attributes must be executed first because dynamic attributes might
rely on them. This is really important when using the :parent relationship.

Previous code didn't work fine in situations like this one:
  Factory.define(:generic_user, :class => User) do |u|
    u.email { |user| "#{user.name}@example.com }
  end

  Factory.define(:flavio, :parent => :generic_user) do |u|
    u.name "flavio"
  end

When building a :user object the previous code would have set the email
attribute and then the name attribute. This results in a user object with
an invalid email address: the 'name' attribute is yet not set while the
'email' attribute is evaluated.

Closes #159
2011-08-05 11:11:34 -04:00
Ari Epstein
b6bd89760f Added spec parent factories that verifies a child can use an attribute set by the parent. 2011-07-13 06:51:51 -07:00
Joshua Clayton
0c0699759f Allow child factories to be defined by nesting 2011-06-29 16:49:45 -04:00
Joe Ferris
6c2322a11d New default syntax for using defined factories 2011-01-26 20:44:24 -05:00
Joe Ferris
2d1c77984b Split up the acceptance spec; removed the acceptance model fixtures in favor of fresh definitions in each spec 2010-11-12 14:58:25 -06:00