Browse files

[Post] - Factory Girl Blocking Rake Database Migrations

Is your factory_girl gem blocking your rake db:migrate? This is how you fix that.
  • Loading branch information...
1 parent 725e276 commit 48b6fc1ed6a3c5ff8b001fd621562716b55bae0e @jwang committed Sep 7, 2011
Showing with 18 additions and 0 deletions.
  1. +18 −0 _posts/
@@ -0,0 +1,18 @@
+layout: post
+title: Factory Girl Blocking Rake Database Migrations
+tags: [ruby, rails, factory_girl]
+categories: blog
+I use a couple of items for doing Behavior Driven Development. Primarily, [Cucumber]( and [RSpec]( In conjunction with those, I use [Factory Girl]( and [Shoulda](
+Sometimes, it seems that Factory Girl can get in the way of running `rake db:migrate` when you push your code up to your source control system, in my case [GitHub](, for others download and run it. Such was the case with the [Jenkins CI]( server.
+#### The Issue
+The problem was that Factory Girl attempts to create factories for models that did not have database tables created yet. It was trying to run before the database migrations ran when the server tried running the `rake db:migrate`. (Note, yes, we always prepend `bundle exec`, but shortened it here for context.)
+#### The Solution
+It seems that you're not to load the `factory\_girl_rails` gem in your Gemfile in the `:development` group at all. The configuration on [the GitHub repo]( just says to add it to your Gemfile, but instead you should add it to your `:test` group only. For example:
+`gem 'factory_girl_rails', :group => :test`
+More details can be found on [the mailing list topic](

0 comments on commit 48b6fc1

Please sign in to comment.