technicalpickles

Open Source ProjectsCode that Might be Useful to You

Talks I've GivenOn Technologies and Ideas

ThoughtsWhere I Sometimes Write Things

Resume If You Still Believe In Those

Follow Me On

GitHubIf coding is your thing

TwitterIf you tweet

Making factory_girl even easier on Rails


factory_girl is pretty sweet. I’m not going over to rehash its awesomeness, but you can check out its website.

Not that it was difficult to use with Rails, but now it’s even easier.

I present to you the-oh-so-creatively-named factory_girl_on_rails.

Install it

script/plugin install git://github.com/technicalpickles/factory_girl_on_rails.git

What it does

This plugin allows you to place factory definitions in test/factories, and the plugin will automatically load them.

Additionally, it provides a simple generator for creating new factories:

./script/generate factory account

This creates an Account factory: test/factories/account_factory.rb

./script/generate factory post title:string body:text published:boolean

This creates a Post factory with a string title, text body, and published flag.

The source

It lives on GitHub: technicalpickles/factory_girl_on_rails

Summary

Overall, this plugin doesn’t do a whole lot, but I had to do this kind of thing by hand on enough projects that I figured it was worth it.

comments powered by Disqus