如何測試在rspec的外鍵關聯,RSPEC對於協會在Active模式
下面是代碼
has_one :store, :foreign_key => "seller_id", :class_name => "Store"
如何寫rspec的此代碼
請告訴我一些建議
如何測試在rspec的外鍵關聯,RSPEC對於協會在Active模式
下面是代碼
has_one :store, :foreign_key => "seller_id", :class_name => "Store"
如何寫rspec的此代碼
請告訴我一些建議
答案是應該匹配寶石。檢查了這一點:https://github.com/thoughtbot/shoulda-matchers
describe Post do
it { should belong_to(:user) }
it { should have_many(:tags).through(:taggings) }
end
describe User do
it { should have_many(:posts) }
end
您正試圖測試基本的Rails功能 - 你不應該這樣做,而不是專注於您的特定應用需求。也就是說,@ gayavat回答你的問題。 – eugen 2012-04-06 11:39:35