1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/spec
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
..
acceptance Ensure static attributes are executed before dynamic ones. 2011-08-05 11:11:34 -04:00
factory_girl Ensure static attributes are executed before dynamic ones. 2011-08-05 11:11:34 -04:00
factory_girl_spec.rb Split factories/sequences into separate registries most of the time; 2011-05-25 20:08:59 -04:00
spec_helper.rb Fixed defined constants interacting in nested contexts 2011-07-05 18:42:57 -04:00