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
|
# frozen_string_literal: true
class ActiveSupport::TestCase
def Build(*args) # rubocop:disable Naming/MethodName
n = args.shift if args.first.is_a?(Numeric)
factory = args.shift
factory_bot_args = args.shift || {}
if n
[].tap do |collection|
n.times.each { collection << FactoryBot.build(factory.to_s.singularize.to_sym, factory_bot_args) }
end
else
FactoryBot.build(factory.to_s.singularize.to_sym, factory_bot_args)
end
end
def Generate(*args) # rubocop:disable Naming/MethodName
n = args.shift if args.first.is_a?(Numeric)
factory = args.shift
factory_bot_args = args.shift || {}
if n
[].tap do |collection|
n.times.each { collection << FactoryBot.create(factory.to_s.singularize.to_sym, factory_bot_args) }
end
else
FactoryBot.create(factory.to_s.singularize.to_sym, factory_bot_args)
end
end
end
|