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

13 commits

Author SHA1 Message Date
Joshua Clayton
b79a525c09 Proxy => Strategy 2012-02-10 18:19:17 -05:00
Joshua Clayton
fba6f332fd Attributes have a to_proc method and are lazily evaluated on an
anonymous class
2011-11-25 21:59:43 -05:00
Joshua Clayton
dc32fd69e8 Change syntax for ignoring attributes to use block syntax instead of
calling ignore on individual declarations.

Old syntax:

    factory :user do
      rockstar(true).ignore
      four { 2 + 2 }.ignore

      name { "John Doe#{" - Rockstar" if rockstar}" }
    end

New syntax:

    factory :user do
      ignore do
        rockstar true
        four     { 2 + 2 }
      end

      name { "John Doe#{" - Rockstar" if rockstar}" }
    end
2011-10-09 16:46:57 -04:00
Joe Ferris
4d30663a5b Callbacks aren't attributes 2011-09-16 17:48:06 -04:00
Joshua Clayton
de2d49914c Style cleanup 2011-09-03 00:25:26 -04:00
Joshua Clayton
7c9254a452 Clean up attribute and core factory specs 2011-08-19 17:21:14 -04:00
Joshua Clayton
554e6ab378 rr => mocha 2011-08-13 00:12:47 -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
Joe Ferris
c59981de1b Split factories/sequences into separate registries most of the time;
Only use factories from step definitions
2011-05-25 20:08:59 -04:00
Joe Ferris
8b4a6a1c3a Moved definition loading syntax out of the factory class; moved everything into a FactoryGirl module 2010-07-06 20:22:02 -04:00
Joe Ferris
f3366b69f2 Separated unit and acceptance tests to isolate Rails-related dependencies 2010-06-10 13:37:51 -04:00
Peter Suschlik
263e7be9da Fix exception message when defining attr writer.
Before this patch the message looked like:
factory_girl uses 'f.test value' syntax rather than 'f.test= = value'

Signed-off-by: Nick Quaranto <nick@quaran.to>
2009-04-20 17:09:20 -04:00
Joe Ferris
683aa43fab Converted tests to specs 2009-04-13 21:15:25 -04:00