1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
# frozen_string_literal: true
require "test_prof/factory_bot"
require "test_prof/factory_all_stub/factory_bot_patch"
module TestProf
# FactoryAllStub inject into FactoryBot to make
# all strategies be `build_stubbed` strategy.
module FactoryAllStub
LOCAL_NAME = :__factory_bot_stub_all__
class << self
def init
# Monkey-patch FactoryBot / FactoryGirl
TestProf::FactoryBot::FactoryRunner.prepend(FactoryBotPatch) if
defined?(TestProf::FactoryBot)
end
def enabled?
Thread.current[LOCAL_NAME] == true
end
def enable!
Thread.current[LOCAL_NAME] = true
end
def disable!
Thread.current[LOCAL_NAME] = false
end
end
end
end
|