Module: TestProf::FactoryProf::FactoryBotPatch

Defined in:
lib/test_prof/factory_prof/factory_bot_patch.rb

Overview

Wrap #run method with FactoryProf tracking

Instance Method Summary collapse

Instance Method Details

#run(strategy = @strategy) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/test_prof/factory_prof/factory_bot_patch.rb', line 7

def run(strategy = @strategy)
  variation = ""

  if FactoryProf.config.include_variations?
    if @traits || @overrides
      unless @traits.empty?
        variation += @traits.sort.join(".").prepend(".")
      end

      unless @overrides.empty?
        variation += @overrides.keys.sort.to_s.gsub(/[\\":]/, "")
      end
    end
  end

  FactoryBuilders::FactoryBot.track(strategy, @name, variation: variation.to_sym) { super }
end