2010-03-12 05:52:16 +01:00
|
|
|
class ActiveSupport::TestCase
|
|
|
|
def Build(*args)
|
|
|
|
n = args.shift if args.first.is_a?(Numeric)
|
|
|
|
factory = args.shift
|
|
|
|
factory_girl_args = args.shift || {}
|
|
|
|
|
|
|
|
if n
|
2010-07-06 18:40:02 +02:00
|
|
|
Array.new.tap do |collection|
|
2010-03-12 05:52:16 +01:00
|
|
|
n.times.each { collection << Factory.build(factory.to_s.singularize.to_sym, factory_girl_args) }
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Factory.build(factory.to_s.singularize.to_sym, factory_girl_args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def Generate(*args)
|
|
|
|
n = args.shift if args.first.is_a?(Numeric)
|
|
|
|
factory = args.shift
|
|
|
|
factory_girl_args = args.shift || {}
|
|
|
|
|
|
|
|
if n
|
2010-07-06 18:40:02 +02:00
|
|
|
Array.new.tap do |collection|
|
2010-03-12 05:52:16 +01:00
|
|
|
n.times.each { collection << Factory.create(factory.to_s.singularize.to_sym, factory_girl_args) }
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Factory.create(factory.to_s.singularize.to_sym, factory_girl_args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|