2015-04-05 111 views
0

用戶有一個配置文件。該配置文件是在創建用戶之後創建的。如何使用rspec測試配置文件是否存在?測試相關模型是否存在

let(:user) { FactoryGirl.create(:student) } 
subject { user } 
it { is_expected.to be_valid } 
it { is_expected.to (#profile exist)) # I don't know what goes here 

回答

1

您可能無法將它寫入一行。這是我的想法 -

let(:user) { FactoryGirl.create(:student) } 
subject { user } 
it { is_expected.to be_valid } 
expect(user.profile).to be_present