Implementing the majority of generic #import tests.
This commit is contained in:
parent
ca5f83e1cf
commit
db173ef907
8 changed files with 252 additions and 56 deletions
29
test/support/generate.rb
Normal file
29
test/support/generate.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
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
|
||||
returning Array.new do |collection|
|
||||
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
|
||||
returning Array.new do |collection|
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue