photo by laffy4k
The other day I wanted to play with some things using
script/console, but was feeling too lazy to set up all of the data I was going to need to do what I wanted. Sure enough after looking at the documentation for fixture_replacement, I can use it there too:
% script/console >> include FixtureReplacement >> cause = create_cause >> user = create_user >> cause.users << userIt is really useful for easily setting up your test data in the spec (or test) that you are writing. Instead of having to go off to the fixture files and add new fixtures (and try to remember to set up all of the dependent fixtures that are needed), you can use new_xxx or create_xxx to get an object to test in a valid state with all its dependent data. Take a look at the FixtureReplacement plugin now.