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/acceptance
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
..
syntax Move strategy calculation to Factory#run 2012-05-04 13:36:46 -04:00
activesupport_instrumentation_spec.rb Introduce new callback syntax 2012-05-04 17:59:34 -04:00
aliases_spec.rb Deprecate the vintage syntax 2012-03-16 16:43:23 -04:00
attribute_aliases_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
attribute_existing_on_object_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
attributes_for_spec.rb Test has_many with attributes_for 2012-04-17 08:38:12 -04:00
attributes_from_instance_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
attributes_ordered_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
build_list_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
build_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
build_stubbed_spec.rb Change lambda {}.should to expect {}.to 2012-04-20 16:58:26 -04:00
callbacks_spec.rb Introduce new callback syntax 2012-05-04 17:59:34 -04:00
create_list_spec.rb Introduce new callback syntax 2012-05-04 17:59:34 -04:00
create_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
define_child_before_parent_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
definition_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
definition_without_block_spec.rb Move DefineConstant code into macro 2011-08-19 17:21:54 -04:00
initialize_with_spec.rb Base class is implied when calling .new within initialize_with 2012-04-23 22:52:59 -05:00
modify_factories_spec.rb Introduce new callback syntax 2012-05-04 17:59:34 -04:00
modify_inherited_spec.rb Deprecate the vintage syntax 2012-03-16 16:43:23 -04:00
nested_attributes_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
overrides_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
parent_spec.rb Introduce new callback syntax 2012-05-04 17:59:34 -04:00
register_strategies_spec.rb Support *_list for all (including custom) strategies 2012-05-04 14:56:22 -04:00
sequence_spec.rb Clean up 2012-04-06 15:33:41 -04:00
skip_create_spec.rb Allow a user to skip the default create execution 2012-04-23 22:40:05 -05:00
stub_spec.rb Use 1.9 hash syntax 2012-03-16 16:43:23 -04:00
syntax_methods_within_dynamic_attributes_spec.rb Implicitly call FactoryGirl's syntax methods from dynamic attributes 2012-04-20 16:00:23 -04:00
traits_spec.rb Introduce new callback syntax 2012-05-04 17:59:34 -04:00
transient_attributes_spec.rb Introduce new callback syntax 2012-05-04 17:59:34 -04:00