9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/factory_bot_instruments/tracing.rb', line 9
def run(build_strategy, overrides, &block)
if $FACTORY_BOT_INSTRUMENTS_TRACING
depth = "| " * $FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH
signature = "#{build_strategy} \e[32m:#{@name}\e[0m"
start = Time.now
puts "#{depth}┌ (start) #{signature}"
$FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH += 1
end
result = original_run(build_strategy, overrides, &block)
if $FACTORY_BOT_INSTRUMENTS_TRACING
duration = format("%4.3fs", Time.now - start)
puts "#{depth}└ (finish) #{signature} [#{duration}]"
$FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH -= 1
end
result
end
|