开发者

How to replace fixture generator on Rails 3?

开发者 https://www.devze.com 2022-12-18 08:45 出处:网络
I am trying to use FactoryGirl instead of default fixtures in edge Rails 3. I used http://github.com/pjb3/rails3-generators

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_un开发者_如何学JAVAit, :fixture => true
  g.fixture_replacement "factory_girl", :dir => "test/factories"
end

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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消