# Extract fixtures to a separate gem for Rails 4

**URL:** <https://discuss.rubyonrails.org/t/extract-fixtures-to-a-separate-gem-for-rails-4/64403>\
**Category:** rubyonrails-core\
**Created:** [July 6, 2012, 11:38am UTC](https://discuss.rubyonrails.org/t/extract-fixtures-to-a-separate-gem-for-rails-4/64403 "2012-07-06T11:38:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rodrigo\_Rosenfeld\_R1](https://avatars.discourse-cdn.com/v4/letter/r/5daacb/32.png) [@Rodrigo\_Rosenfeld\_R1](https://discuss.rubyonrails.org/u/Rodrigo_Rosenfeld_R1)\
**Post date:** [July 6, 2012, 11:38am UTC](https://discuss.rubyonrails.org/t/extract-fixtures-to-a-separate-gem-for-rails-4/64403/1 "2012-07-06T11:38:01Z")

</div>

One of the reasons I prefer factories over fixtures is that my tests express better.

```
login_user = Factory.create :user

login_as login_user

...

In this case, someone reading this test knows that it only matters

```

that a user is being created. It shouldn’t have any special attributes.

```
But if I do something like this:

login_user = Factory.create :user, name: 'Rodrigo'

Then I know that the name attribute of the user is relevant for that

```

test.

```
Another reason is that I only load the records needed by my tests,

```

not lots of unrelated data that could have some side effect on the tests.

```
Best,

Rodrigo.

```

---

<div class="post-metadata">

**Author:** ![G\_Sobrinho](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@G\_Sobrinho](https://discuss.rubyonrails.org/u/G_Sobrinho)\
**Post date:** [July 6, 2012, 12:30pm UTC](https://discuss.rubyonrails.org/t/extract-fixtures-to-a-separate-gem-for-rails-4/64403/2 "2012-07-06T12:30:52Z")

</div>

My vote is to extract to a external gem.

It’s fine if you like fixtures, but it’s fine if you like factories too.

I think the benefit of release cycle decoupled from rails will be valuable.

What are the downsides?

---

<div class="post-metadata">

**Author:** ![fxn](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/fxn/32/12956_2.png) [@fxn](https://discuss.rubyonrails.org/u/fxn)\
**Post date:** [July 6, 2012, 4:22pm UTC](https://discuss.rubyonrails.org/t/extract-fixtures-to-a-separate-gem-for-rails-4/64403/3 "2012-07-06T16:22:19Z")

</div>

Absolutely.

Rails provides a curated stack. The stack reflects the preferences of the core team, we make some choices that we believe are the best defaults. For instance, when we compare Test::Unit and RSpec code side by side we prefer Test::Unit, and that’s what you get in the stack. Same for fixtures.

In addition to that, the framework also makes the design/development effort to let users be able to plug in alternatives, and Rails 3 made this less hackish than it was before. So it is totally fine that you prefer factories, and we’ll make sure you can use them.

---

<div class="post-metadata">

**Author:** ![G\_Sobrinho](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@G\_Sobrinho](https://discuss.rubyonrails.org/u/G_Sobrinho)\
**Post date:** [July 6, 2012, 4:30pm UTC](https://discuss.rubyonrails.org/t/extract-fixtures-to-a-separate-gem-for-rails-4/64403/4 "2012-07-06T16:30:46Z")

</div>

I see.

What about release cycle?

---

<div class="post-metadata">

**Author:** ![fxn](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/fxn/32/12956_2.png) [@fxn](https://discuss.rubyonrails.org/u/fxn)\
**Post date:** [July 6, 2012, 6:52pm UTC](https://discuss.rubyonrails.org/t/extract-fixtures-to-a-separate-gem-for-rails-4/64403/5 "2012-07-06T18:52:50Z")

</div>

Well, in the case of Rails the value of extracting something like this to a gem has more to do with the internal organization of the framework in my view.

Things in Rails follow the release cycle of Rails generally speaking. For example, Active Record is a gem, but there aren’t releases of Active Record independent from Rails, albeit it can be used outside Rails.

I don’t see a need to extract fixtures to a gem personally.

---

<div class="post-metadata">

**Author:** ![G\_Sobrinho](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@G\_Sobrinho](https://discuss.rubyonrails.org/u/G_Sobrinho)\
**Post date:** [July 6, 2012, 7:00pm UTC](https://discuss.rubyonrails.org/t/extract-fixtures-to-a-separate-gem-for-rails-4/64403/6 "2012-07-06T19:00:07Z")

</div>

ok, thanks for explanation Xavier 🙂
