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/factory_girl
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
..
attribute Move class creation/handling to an anonymous evaluator 2011-11-30 20:56:58 -05:00
declaration Attributes have a to_proc method and are lazily evaluated on an 2011-11-25 21:59:43 -05:00
proxy Clean up proxy specs 2011-12-30 00:41:50 -05:00
aliases_spec.rb Clean up attribute and core factory specs 2011-08-19 17:21:14 -04:00
attribute_list_spec.rb Add AttributeList#associations 2011-12-30 01:01:04 -05:00
attribute_spec.rb Attributes have a to_proc method and are lazily evaluated on an 2011-11-25 21:59:43 -05:00
callback_spec.rb Use objects, not structs 2011-09-16 17:48:06 -04:00
declaration_list_spec.rb Wrap up DeclarationList 2011-10-31 19:05:34 -04:00
definition_proxy_spec.rb Implement initialize_with to allow overriding object instantiation 2012-01-20 15:37:36 -05:00
definition_spec.rb Fix issues with inline traits not taking precedence 2012-01-18 10:14:21 -05:00
deprecated_spec.rb Suggestions 2011-08-19 17:22:10 -04:00
evaluator_class_definer_spec.rb Factory evaluators use inheritance 2012-01-09 17:28:20 -05:00
factory_spec.rb Fix issues with inline traits not taking precedence 2012-01-18 10:14:21 -05:00
find_definitions_spec.rb No more "should"'s in the example descriptions. 2011-10-14 10:09:51 -04:00
null_factory_spec.rb Implement initialize_with to allow overriding object instantiation 2012-01-20 15:37:36 -05:00
null_object_spec.rb Add NullObject 2012-01-08 00:23:25 -05:00
proxy_spec.rb Clean up proxy specs 2011-12-30 00:41:50 -05:00
registry_spec.rb Registries are named 2011-10-15 02:01:16 -04:00
sequence_spec.rb Clean up attribute and core factory specs 2011-08-19 17:21:14 -04:00