Testing a build association using Rspec in Rails 3
问题 I have the following line in my create action of my teachers controller. @rating = @teacher.ratings.build(params[:rating]) unless params[:rating][:rating].blank? I know my associations are correct because this line correctly creates a new rating alongside a new teacher unless the rating is left blank. However I'm trying my best to follow TDD and I have no clue as to how to test that line using rspec. I'm kind of at a loss. I'm using factory girl and shoulda if that helps. 回答1: You can say