I was wondering what is the best way to test associated models with rspec. Particularly I have a projects model that has_many stories. When I go to the projects show action it also lists all the stories associated to that project. I cant seem to get a test to work. I have tried the following:
it "populates an array of user stories associated to @project" do project = FactoryGirl.create(:project) user_story = FactoryGirl.create(:user_story, project_id: project.id) get :show, id: project expect(assigns(:user_stories)).to eq(user_story) end
If anyone can point me in the right directions it would be very much appreciated.