ruby - How can fixtures be replaced with factories using rails3-generators? -
i'm trying replace fixture generation factories using rails3-generators:
https://github.com/indirect/rails3-generators#readme
the gem included in gemfile , has been installed:
# gemfile gem 'rails3-generators', :group => :development
i added following application.rb:
# application.rb config.generators |g| g.stylesheets false g.fixture_replacement :factory_girl end
yet 'rails g model insect' still generating fixtures ('insects.yml'). working others using rails 3.0.4 , rails3-generators 0.17.4?
'rails g' shows new generators available (such authlogic , koala), 'rails g model' still lists fixtures , doesn't refer factories.
what else should add work? thanks.
edit: ran gem's test suite, includes test this, , passes. no clue why doesn't work app.
edit2: tried again test project , same result: fixtures instead of factories. if confirm whether works them rails 3.0.4 , rails3-generators 0.17.4, helpful because imply i'm doing wrong projects.
edit3: works if run 'rails g model insect -r factory_girl'. thought generator configuration in application.rb supposed take care of that, seems source of problem.
searching around found following, may help:
try specifying directory option
factory_girl
's factories:config.generators |g| g.stylesheets false g.fixture_replacement :factory_girl, :dir => "spec/factories" # or test/factories, case may end
if you're using
test::unit
, try following:config.generators |g| g.stylesheets false g.test_framework :test_unit, :fixture_replacement => :factory_girl end
in both cases still need rails3-generators
gem, although there push functionality factory_girl_rails
.
this rails bug indicates that, @ point, g.fixture_replacement
code may not have worked right. perhaps test in 3.0.5 in order. :)
Comments
Post a Comment