Module: TestProf::EventProf::CustomEvents::FactoryCreate

Defined in:
lib/test_prof/event_prof/custom_events/factory_create.rb

Overview

:nodoc: all

Defined Under Namespace

Modules: RunnerPatch

Class Method Summary collapse

Class Method Details

.setup!Object



15
16
17
18
# File 'lib/test_prof/event_prof/custom_events/factory_create.rb', line 15

def setup!
  @depth = 0
  FactoryGirl::FactoryRunner.prepend RunnerPatch
end

.track(factory) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/test_prof/event_prof/custom_events/factory_create.rb', line 20

def track(factory)
  @depth += 1
  res = nil
  begin
    res =
      if @depth == 1
        ActiveSupport::Notifications.instrument(
          'factory.create',
          name: factory
        ) { yield }
      else
        yield
      end
  ensure
    @depth -= 1
  end
  res
end