Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace fixture generator on Rails 3?

I am trying to use FactoryGirl instead of default fixtures in edge Rails 3. I used

http://github.com/pjb3/rails3-generators

and tried to do the replacement as adviced in

http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3

this way (config/application.rb)

config.generators do |g|
  g.orm             :active_record
  g.template_engine :erb
  g.test_framework  :test_unit, :fixture => true
  g.fixture_replacement "factory_girl", :dir => "test/factories"
end

looks good, isn't it? But it does not work ... any ideas?

like image 471
Jakub Avatar asked Jan 23 '10 14:01

Jakub


2 Answers

It seems that the proper way to do it (at least for now :)) is slightly different:

config.generators do |g|
  g.orm             :active_record
  g.template_engine :erb
  g.test_framework  :test_unit, :fixture_replacement => :factory_girl
end
like image 155
szimek Avatar answered Nov 04 '22 09:11

szimek


For Rails 3.1.rc1 you need "gem 'rails3-generators'" in your Gemfile for the factory_girl fixture replacement to work.

like image 27
dvdplm Avatar answered Nov 04 '22 10:11

dvdplm