2016-10-21 79 views

回答

1

只能測試,整個模型是有效的。不過,您可以測試package屬性是否有錯誤。

context 'validations' do 
let(:super_campaign){FactoryGirl.create(:super_campaign)} 
    context 'package' do 
    it "Package should be present" do 
    expect(super_campaign).to be_valid 
    expect(super_campaign.errors[:package]).to be_nil 
    end 
    end 
end 
2
expect(super_campaign).to be_valid # AR object, not it's attribute 
+0

你正在接聽45秒,我花了更多的時間來鍵入這個答案:( – Sajan

相關問題