Loading/defining fabricators in plugins

Are there any examples of plugins defining Fabricators?

I found something here that may be relevant: How to lazy load fabricators · Issue #167 · paulelliott/fabrication · GitHub

It says that it clears existing fabricators…

It’s actually quite simple. :slight_smile:

  • add spec/plugin_helper.rb to your plugin if you haven’t got that already.
  • create a folder spec/fabricators and add your factories in there
  • require the *rb files in plugin_helper.rb
2 个赞

我也有在我的插件中定义自定义 fabricators 的需求,但令我惊讶的是,我们还没有对此提供适当的支持。

一旦上述 PR 被合并,只要 fabricators 存在于插件的 spec/fabricators 文件夹中,它们就会被自动引入。

2 个赞