【发布时间】:2016-06-14 09:19:59
【问题描述】:
当使用 Shoulda / RSpec 测试 validate_presence_of 的多个属性时,我得到这些长且重复的代码块,如下所示:
it { should validate_presence_of(:text) }
it { should validate_presence_of(:user) }
it { should validate_presence_of(:commentable) }
[...]
有没有办法把它弄干?像这样的:
it { should validate_presence_of(:text, :user, :commentable,...) }
【问题讨论】: