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

7 commits

Author SHA1 Message Date
yoshitake.nakaji
95c6d96306 Include additional information in AS::Notifications instrumentation
This includes additional data about the factory instance, including
traits, overrides, and the factory itself.
2015-08-01 23:14:16 -04:00
Joshua Clayton
b095f24598 Convert to expect syntax 2013-01-18 13:58:36 -05:00
Joshua Clayton
d475033a81 Write a test that doesn't suck 2012-05-05 00:08:39 -04:00
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
Joshua Clayton
ff0e6fb6c0 Fix Appraisal dependencies and get suite green
The twiddle-wakka specifying only major and minor (not tiny) versions
will grab latest minor, which ended up being 3.2 for all versions of
Rails supported. This ensures that when we report supporting Rails 3.0,
3.1, and 3.2, we actually test against those versions.

It also backports ActiveSupport::Notifications.subscribed, which was
added in 3.2.

Closes #367
2012-05-03 00:36:58 -04:00
Joshua Clayton
fa4fd9efa7 Make AS::Notifications time test a bit more lenient 2012-04-24 16:16:46 -05:00
Joshua Clayton
925a947be0 Use ActiveSupport::Notifications for pub/sub of factory usage 2012-04-24 10:30:20 -05:00