I normally use this step to set up records with factory_girl:
Given /^the following (.+) records?:$/ do |factory, table|
table.hashes.each do |hash|
Factory(factory, hash)
end
end
And here's my work-around when setting up associations:
Given the following group record:
| id | name |
| 1 | foo |
And the following item records:
| name | group_id |
| bar | 1 |
| baz | 1 |
# ...
I know this is bad. Using ids makes the whole thing brittle and cryptic from the vantage of the domain person.
So, my question is -- what would be the best practice to set up an association with factory_girl and a table argument like the one above?