0

所以我有一个带有制造商的父类和两个子类。如何让子类引用父类的制造商来设置共享代码?

例如

Fabricator(:parent) do
    important_variable "Foo"
    lesser_variable "Bar
end

Fabricator(:child1) do
    //Not sure I actually need anything in here
end


Fabricator(:child2) do
    //Again, not sure I actually need anything in here
end

Fabricate(:child).important_variable #Foo
Fabricate(:child).lesser_variable #Bar
4

1 回答 1

1

您可以from像这样将参数传递给孩子:

Fabricator(:child1, from: :parent) do
  //Not sure I actually need anything in here
end


Fabricator(:child2, from: :parent) do
  //Again, not sure I actually need anything in here
end

您可以在制造文档中阅读更多相关信息。

https://www.fabricationgem.org/#defining-fabricators

于 2016-10-21T14:04:32.013 回答