2

有没有更好的方法来编写这个规范?这可行,我不喜欢我必须调用f.valid?才能填充 f.errors 的事实。

it "fails to save the record because the name is blank" do
  f = Foo.new
  f.valid?
  f.errors.include?(:name).should be_true
end
4

1 回答 1

4
it "fails to save the record because the name is blank" do
  Foo.create.errors.should include :name
end
于 2012-06-14T00:56:51.910 回答