I am using RSpec 2 and trying to load a few instance variables at the top of a model spec. They are associated, but the associations aren't coming through.
The models are Column and Table -- this is not a problem the way we have it set up. Table has_many columns.
let!(:company) { Company.first }
let!(:events_table) { Table.create(name: "Events Test") }
let!(:text_column) { Column.create(title: "Title", name: "title", column_type: "text", table_id: events_table.id)}
let!(:start_date_column) { Column.create(title: "Start Date", name: "start_date", column_type: "date", table_id: events_table.id) }
The events_table is definitely getting created and returning an ID if I puts.attributes on it later on. I thought the lets! with the bang woudl allow it to get created in order so the association would exist.
I'm not sure that's happening though.
If I puts out the attributes for either of the columns, the table_id is nil.
How can I ensure it is not nil? What am I doing wrong?
Thanks in advance!!
Aucun commentaire:
Enregistrer un commentaire