0
我得到了一個名爲Candidate的Devise模型。設計模型應該驗證:電子郵件不能爲空(我不測試電子郵件)
而且我得到了這個測試:
it { expect(subject).to validate_presence_of(:democracyengine_recipient_id) }
而此行的模式:
validates :democracyengine_recipient_id, presence: true
和驗證工作(在其他測試)。
但在這個特殊的測試中,我得到這個錯誤:
Failure/Error: it { expect(subject).to validate_presence_of(:democracyengine_recipient_id) }
Expected errors to include "can't be blank" when democracyengine_recipient_id is set to nil, got errors: ["email can't be blank (\"\")", "password can't be blank (nil)"]
如何解決呢?