Hello,
After reading the recent blog post at
http://collectiveidea.com/blog/archives/2014/08/06/time-to-bring-back-fixtures/, I was intrigued by some of the ideas. For example, nearly every single one of my fabricators references some account or user or other "owner" object, which results in lots of extra records created and time wasted.
```ruby
Fabricator :widget do
account
name { ... }
end
```
I also often times want to create several "sibling" objects with the same account, which requires a bit more boilerplate:
```ruby
let(:account) { Fabricate(:account) }
let(:widget_a) { Fabricate(:widget, account: account) }
let(:widget_b) { Fabricate(:widget, account: account) }
```
I think by having that initial account defined as a fixture would solve both problems, first by only ever creating the one account, and having all fabricators default to using it:
```ruby
Fabricator :widget do
account { accounts(:primary_account) }
name { ... }
end
```
I spent a little bit of time trying to hack this together, but failed. The issue was making the Rails `#accounts` fixture helper available in the fabrication Runner. But before I spent too much time on this, I wanted to get your opinion on if this was even a good idea, and if so, any feedback on how best to accomplish this.
I was hoping it would be something as simple as `Fabrication::Schematic::Runner.send(:include, ActiveRecord::
TestFixtures)`, but no dice. Any tips?
Thanks,
Paul