# Loading/defining fabricators in plugins

**URL:** https://meta.discourse.org/t/loading-defining-fabricators-in-plugins/126896
**Category:** Development
**Created:** [August 27, 2019, 5:07am UTC](https://meta.discourse.org/t/loading-defining-fabricators-in-plugins/126896 "2019-08-27T05:07:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rimian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rimian/32/120658_2.png) [@rimian](https://meta.discourse.org/u/rimian)
#### Post date: [August 27, 2019, 5:07am UTC](https://meta.discourse.org/t/loading-defining-fabricators-in-plugins/126896/1 "2019-08-27T05:07:48Z")

</div>

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](https://github.com/paulelliott/fabrication/issues/167)

It says that it clears existing fabricators…

---

<div class="post-metadata">

### Author: ![rimian](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rimian/32/120658_2.png) [@rimian](https://meta.discourse.org/u/rimian)
#### Post date: [August 27, 2019, 5:26am UTC](https://meta.discourse.org/t/loading-defining-fabricators-in-plugins/126896/2 "2019-08-27T05:26:15Z")

</div>

It’s actually quite simple. 🙂

- 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`

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [November 26, 2021, 6:19am UTC](https://meta.discourse.org/t/loading-defining-fabricators-in-plugins/126896/3 "2021-11-26T06:19:53Z")

</div>

I had a need to define custom fabricators in my plugin as well and was surprised that we don’t already have proper support for it.

[https://github.com/discourse/discourse/pull/15106](https://github.com/discourse/discourse/pull/15106)

Once the above PR has been merged, your fabricators will automatically be required as long as they exists in the plugin’s `spec/fabricators` folder.
