测试相关模型是否存在
问题描述:
用户有一个配置文件。该配置文件是在创建用户之后创建的。如何使用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
答
您可能无法将它写入一行。这是我的想法 -
let(:user) { FactoryGirl.create(:student) }
subject { user }
it { is_expected.to be_valid }
expect(user.profile).to be_present