Friday, 14 August 2009

a sight for sore eyes

Started
................................................................
Finished in 3.983101 seconds.

64 tests, 166 assertions, 0 failures, 0 errors


Unit tests with Factory Girl

Getting the HABTM working was a tricky thing. In the end I had to do this:

def setup
@job = Factory.create(:job)
@version = Factory.build(:version, :job_id =>@job.id)
@printer_set_up = Factory.build(:printer_set_up)

3.times {
pf = Factory.create(:printer_format)
@printer_set_up.printer_formats << page_assembly =" Factory.create(:page_assembly," printer_id =""> @printer_set_up.printer_id, :job_id => @job.id)
end


PrinterFormat and PrinterSetUp both have HABTM relationships with each other.

No comments:

Post a Comment