我在rails模型中有自定义验证:
validate :custom_validation_method
def custom_validation_method
# do stuff here
end
我如何为此制作RSpec?谢谢!
答案 0 :(得分:1)
测试验证(任何)
describe MyClass do
it '#custom_validation' do
expect(subject.valid?).to be_falsey
#do stuff to subject to make it valid
expect(subject.valid?).to be_truthy
end
end