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

26 commits

Author SHA1 Message Date
Joshua Clayton
8209a461ee Remove dependency on build_class in Evaluator 2012-07-24 18:50:11 -04:00
Joshua Clayton
9bc8e50b44 Refer to the correct attribute 2012-06-08 17:06:19 -04:00
Joshua Clayton
2b50190a07 Make hash of public attributes available within the initialize_with block
Closes #344
2012-06-08 17:05:36 -04:00
Joshua Clayton
a5b3a97c9d Optionally disable duplicate assignment of attributes in initialize_with
By setting:

    FactoryGirl.duplicate_attribute_assignment_from_initialize_with =
false

This turns off duplicate assignment of attributes accessed from
initialize_with. This means any attributes accessed from the factory and
assigned in the initialize_with block won't be subsequently set after
the object has been instantiated.

This will be the default functionality in 4.0.

Closes #345
2012-05-18 17:38:23 -04:00
Joshua Clayton
f1fd650048 Clean up documentation 2012-05-05 02:31:31 -04:00
Joshua Clayton
b84ccd9d09 Add AttributeList#names to map all names for attributes in the list 2012-04-24 16:40:29 -05:00
Joshua Clayton
a16e5eb22e Move ignored/non-ignored filtering logic to AttributeList 2012-04-24 16:20:44 -05:00
Joshua Clayton
0aadd703a5 Follow Ruby conventions of double-under's on each side of the method name 2012-04-20 22:33:54 -04:00
Joshua Clayton
29a5ab1a89 Implicitly call FactoryGirl's syntax methods from dynamic attributes 2012-04-20 16:00:23 -04:00
Joshua Clayton
f5d4db1085 Ensure attributes set on instance are calculated uniquely
This fixes a bug where assignment occurs multiple times; in the case of
nested attributes, assignment mutates the instance, meaning that it
occurring multiple times will cause issues.

Closes #314
2012-03-16 13:04:31 -04:00
Ian Duggan
0d7520e825 Do not ignore alias names of transient attributes. (Fixes #311)
https://github.com/thoughtbot/factory_girl/issues/311
2012-03-13 17:14:42 -07:00
Joshua Clayton
578036480f Implement initialize_with to allow overriding object instantiation
Factory Girl now allows factories to override object instantiation. This
means factories can use factory methods (e.g. methods other than new) as
well as pass arguments explicitly.

    factory :user do
      ignore do
        things { ["thing 1", "thing 2"] }
      end

      initialize_with { User.construct_with_things(things) }
    end

    factory :report_generator do
      ignore do
        name { "Generic Report" }
        data { {:foo => "bar", :baz => "buzz"} }
      end

      initialize_with { ReportGenerator.new(name, data) }
    end

Whitespace

Code recommendations
2012-01-20 15:37:36 -05:00
Joshua Clayton
40242e903b Don't require AS's basic object 2012-01-13 14:20:16 -05:00
Joshua Clayton
f2e41389ea Factory evaluators use inheritance 2012-01-09 17:28:20 -05:00
Joshua Clayton
1c7eab13d6 Add NullObject 2012-01-08 00:23:25 -05:00
Joshua Clayton
d9e0372345 Mimic BasicObject without using BasicObject 2012-01-07 22:52:59 -05:00
Joshua Clayton
d918c1ddae Allow methods to be called from the instance in factory girl attributes
This fixes a regression introduced with the introduction of the
anonymous class.

Closes #264
2012-01-07 22:13:38 -05:00
Joshua Clayton
7254a81072 Add AttributeList#associations 2011-12-30 01:01:04 -05:00
Joshua Clayton
7a8dcd2c37 Clean up block variable name 2011-12-30 01:00:33 -05:00
Joshua Clayton
d1207cda75 Clean up method name 2011-12-30 00:41:50 -05:00
Joshua Clayton
105e892dd2 Get aliases working 2011-12-30 00:41:50 -05:00
Joshua Clayton
410b26c934 Remove unused #set from Proxy::AttributesFor 2011-12-30 00:41:49 -05:00
Joshua Clayton
d3f6090a8f Expose @overrides through a instance method 2011-12-30 00:41:49 -05:00
Joshua Clayton
2e15a3f429 Change ivar name 2011-12-30 00:41:49 -05:00
Joshua Clayton
9cee12a8dc WIP: Remove runner and get acceptance tests green 2011-12-30 00:41:48 -05:00
Joshua Clayton
3eccbc5de0 Add AttributeAssigner to handle attribute assignment on the build class instance 2011-12-30 00:41:48 -05:00