Reputation: 20815
Is there a better way to write this spec? This works but I don't like the fact that I have to call f.valid?
to get f.errors to populate.
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
Upvotes: 2
Views: 841
Reputation: 27779
it "fails to save the record because the name is blank" do
Foo.create.errors.should include :name
end
Upvotes: 4