thoughtbot--factory_bot/lib/factory_girl
Josh Clayton and Jason Draper bef5a01b31 Introduce new callback syntax
Instead of calling before_create, after_build, after_create, or
after_stub, you can now call:

    before(:create) {|instance| instance.name = "overridden!" }
    after(:create)  {|instance| instance.name = "overridden!" }
    after(:build)   {|instance| instance.name = "overridden!" }
    after(:stub)    {|instance| instance.name = "overridden!" }

Additionally, you can declare callbacks longhand:

    callback(:after_stub) {|instance| instance.name = "overridden!" }

This allows for custom callbacks to be defined:

    callback(:custom_callback) {|instance| instance.name = "overridden!" }

Which can then be used from a custom strategy:

    class CustomStrategy
      def association(runner); end

      def result(evaluation)
        evaluation.object.tap do |instance|
          evaluation.notify(:custom_callback, instance)
        end
      end
    end

    FactoryGirl.register_strategy(:custom, CustomStrategy)

This would allow for calling:

    FactoryGirl.custom(:user)

Which would return the user instance but execute the :custom_callback callback
on the user instance first.
2012-05-04 17:59:34 -04:00
..
attribute Use Ruby 1.9's stabby lambdas 2012-04-20 16:59:39 -04:00
declaration Fix callback handling from implicit traits 2011-10-30 23:17:03 -04:00
strategy Don't refer to strategies by class anywhere 2012-04-25 15:03:10 -05:00
syntax Support *_list for all (including custom) strategies 2012-05-04 14:56:22 -04:00
aliases.rb Clean up attribute and core factory specs 2011-08-19 17:21:14 -04:00
attribute.rb Whitespace 2012-04-24 15:11:40 -05:00
attribute_assigner.rb Add AttributeList#names to map all names for attributes in the list 2012-04-24 16:40:29 -05:00
attribute_list.rb Add AttributeList#names to map all names for attributes in the list 2012-04-24 16:40:29 -05:00
callback.rb Allow implicit syntax methods in callbacks 2012-05-04 10:48:52 -04:00
callbacks_observer.rb Rename CallbackRunner to CallbacksObserver since it's an observer 2012-04-20 16:41:27 -04:00
declaration.rb Remove deprecated way of ignoring attributes 2012-03-16 13:17:15 -04:00
declaration_list.rb Wrap up DeclarationList 2011-10-31 19:05:34 -04:00
definition.rb Use Ruby 1.9's stabby lambdas 2012-04-20 16:59:39 -04:00
definition_proxy.rb Introduce new callback syntax 2012-05-04 17:59:34 -04:00
disallows_duplicates_registry.rb Clean up Registry decorator 2012-04-23 21:35:36 -05:00
errors.rb Deprecate the vintage syntax 2012-03-16 16:43:23 -04:00
evaluation.rb Refactor Strategies 2012-04-13 17:20:02 -04:00
evaluator.rb Don't refer to strategies by class anywhere 2012-04-25 15:03:10 -05:00
evaluator_class_definer.rb Refactor Strategies 2012-04-13 17:20:02 -04:00
factory.rb Move strategy calculation to Factory#run 2012-05-04 13:36:46 -04:00
factory_runner.rb Support *_list for all (including custom) strategies 2012-05-04 14:56:22 -04:00
find_definitions.rb Load definition files instead of require so re-running find_definitions works as expected 2011-07-29 14:00:08 -04:00
null_factory.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
null_object.rb Implicitly call FactoryGirl's syntax methods from dynamic attributes 2012-04-20 16:00:23 -04:00
registry.rb Clean up Registry decorator 2012-04-23 21:35:36 -05:00
reload.rb Add ability to register custom strategies 2012-04-23 21:28:20 -05:00
sequence.rb Clean up 2012-04-06 15:33:41 -04:00
step_definitions.rb Move attribute_names_for_model so steps are grouped together 2012-03-30 11:47:46 -04:00
strategy_calculator.rb Clean up Registry decorator 2012-04-23 21:35:36 -05:00
strategy_syntax_method_registrar.rb Support *_list for all (including custom) strategies 2012-05-04 14:56:22 -04:00
syntax.rb Deprecate alternate syntaxes 2012-04-23 16:46:42 -05:00
syntax_runner.rb Implicitly call FactoryGirl's syntax methods from dynamic attributes 2012-04-20 16:00:23 -04:00
trait.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
version.rb Whitespace 2012-04-24 15:11:40 -05:00