Rails plugin that generates factory_girl Factories for all ActiveRecord models
Ruby
Switch branches/tags
Nothing to show
Latest commit f39f326 Dec 23, 2009 Aqab Bin Talal committed with Serialized fields will have be assigned an empty hash instead of 'foo'

README.textile

Sweatshop

A Rails plugin that generates factory_girl Factories for all of your ActiveRecord models.

Requirements

You should probably have the factory_girl gem installed

How to Install & Use

  1. Install the factory_girl gem
    
    gem install factory_girl
    
  1. Install the plugin
    
    ./script/plugin install git://github.com/mdarby/sweatshop.git
    
  1. Run the following rake task to generate your Factories
    
    rake sweatshop:generate
    
  1. Make sure you put the two following lines into spec/spec_helper.rb:
    
    require 'factory_girl'
    Dir.glob("#{RAILS_ROOT}/spec/factories/*.rb").each{|factory| require factory}
    
  1. Your Factories will now be automatically included whenever you run your specs.

That’s it!

Notes

I use RSpec for my BDD habit; you might use something else. Those two lines I mention above can be used in Test::Unit, I’m sure. However, it’s up to you to figure out ;)

About the Author

My name is Matt Darby. I’m a 29 year old professional Web Developer and IT Manager. I am the IT Manager and Lead Web Developer at Dynamix Engineering and recently earned a Master’s Degree in Computer Science from Franklin University in Columbus, OH.

Feel free to check out my blog or to recommend me