Factory Girl Hits 3.0!

Factory Girl is now 3.0! It’s been a wonderful eight months and I’m really excited about what we’ve added in 2.x. We’ve adopted semantic versioning and it’s been a good way to ensure that we’re providing software that’s reliable and stable.

The Big Changes

No more Ruby 1.8 support

You heard correctly; FactoryGirl requires Ruby 1.9+. We want to continue to move forward and supporting 1.8 was something we felt was holding us back. Ruby 1.9 introduces awesomeness like BasicObject, something we had to backport to 1.8 with ActiveSupport — no more!

If you can’t upgrade to Ruby 1.9 and Rails 3, you can continue to use factory_girl_rails version 1.x and FactoryGirl 2.x; those will continue to support Ruby 1.8.7+ and Rails 2.3.9+.

No more Rails 2 support

FactoryGirl 3.0 now only supports Rails 3.x. This will allow us to move forward without having to worry about outdated versions of gems like ActiveSupport.

Vintage syntax deprecated

The vintage syntax has been deprecated and will be removed in the next major release. For those who don’t know what the vintage syntax is, it follows any of these forms:


Factory.define(:admin_user, :parent => :user) do |admin|
  admin.admin true

The alternates for each of these would be (after configuring FactoryGirl to play nicely with RSpec, Test::Unit, or Cucumber):


factory :admin, parent: :user do
  admin true

We chose to do this because the new syntax is awesome and more concise. Plus, repeating Factory.define thirty or forty times in a single file is gross.


To upgrade in a Rails app, just update your Gemfile:

group :test do
  gem "factory_girl_rails", "~> 3.0"

If you’re not running Rails:

gem "factory_girl", "~> 3.0"

What’s next

Factory Girl 2.x introduced a cleaner syntax, traits, ignored attributes, creating multiple records at a time, custom constructors, and more. There are some awesome ideas floating around for 3.x, including separating associations from foreign keys, cleaning up how custom constructors work, ways to define both custom callbacks and custom strategies, and more. Keep your eyes peeled as we move forward!