Factory girl associations and rspec


I am trying to test factory girl associations basically I have a user
model and status model , what is supposed to happen is a user has many
statuses and a status belongs to a user. I have tried to model this in
factory girl as you can see in the files. When I try to execute the test
I get
Failure/Error: visit("/users/#{user.id}/statuses/#{status.id}")
Couldn’t find Status with id=2 [WHERE statuses.user_id = 1]
when I run the request spec for statuses. What should I change to get
this test to pass.


That’s because users are actually different. To fix this you need to
pass a
user record into the FactoryGirl’s create method.

let(:user) {FactoryGirl.create(:user)}
let(:status) {FactoryGirl.create(:status, user: user)}


, 12 2012 ., 14:03:19 UTC+4 Ruby-Forum.com
User :