Avatar Edgar González

  • Random
  • Archive
  • RSS

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

    • #rails
    • #rails3
    • #fixtures
    • #factory_girl
    • #generators
    • #RSpec
    • #test
  • 1 year ago
  • 7
  • Comments
  • Permalink
  • Share
    Tweet

7 Notes/ Hide

  1. jinpu reblogged this from edgar
  2. edgar posted this

Recent comments

Blog comments powered by Disqus
← Previous • Next →

Portrait/Logo

About

When I'm not spending time with Jessica and my kids, I build web applications. Rails developer, believer of Agile Development and Lean startups. NoSQL enthusiast.
CTO and Lord of the API at Piictu

Me, Elsewhere

  • @edgar on Twitter
  • Facebook Profile
  • edgargonzaleznetve on Youtube
  • egg on Flickr
  • edgar on Foursquare
  • My Skype Info
  • Linkedin Profile
  • edgar on github

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr