Replacing fixture generation on Rails 3
Because I don’t like fixtures (I use factory_girl), I change my Rails generators to generate factories instead of fixtures
To do this, just add this to your config/application.rb:
config.generators do |g| g.test_framework :test_unit, :fixture_replacement => :factory_girl end
But in my case, because I prefer rspec instead of test_unit, I use this:
config.generators do |g| g.fixture_replacement :factory_girl, :dir => "spec/factories" end
Changing the factories directory from test/factories (default) to spec/factories.
Because I’m using the rspec-rails gem, I don’t have to define the test framework (but I can), so this works too:
config.generators do |g| g.test_framework :rspec g.fixture_replacement :factory_girl, :dir => "spec/factories" end