mdarby / sweatshop

Rails plugin that generates factory_girl Factories for all ActiveRecord models

This URL has Read+Write access

name age message
file MIT-LICENSE Sun Oct 19 20:13:12 -0700 2008 I present Sweatshop [mdarby]
file README.textile Loading commit data...
file Rakefile Sun Oct 19 20:13:12 -0700 2008 I present Sweatshop [mdarby]
file init.rb Sun Oct 19 20:18:10 -0700 2008 Oops... [mdarby]
file install.rb Sun Oct 19 20:13:12 -0700 2008 I present Sweatshop [mdarby]
directory lib/ Sun Oct 19 20:13:12 -0700 2008 I present Sweatshop [mdarby]
directory tasks/
directory test/ Sun Oct 19 20:13:12 -0700 2008 I present Sweatshop [mdarby]
file uninstall.rb Sun Oct 19 20:13:12 -0700 2008 I present Sweatshop [mdarby]
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