Friday, February 5, 2010

Running Shoulda & Factory Girl in Rails 3

Rails 3 uses Bundler gem to handle gem dependencies. Encountered some problems with Shoulda and Factory Girl.

# Gemfile

group :test do
gem "shoulda"
gem "factory_girl"
end

Shoulda and Factory Girl macros are not loaded so I had to require the gems in test/test_helper.rb

# test/test_helper.rb

require 'shoulda'
require 'factory_girl'
Factory.definition_file_paths = [ File.join(Rails.root, 'test', 'factories') ]
Factory.find_definitions

No comments: