Add specs for allow_nil and allow_blank with attribute value cache active

This commit is contained in:
Adam Meehan 2012-02-01 21:25:42 +11:00
parent 3f4615e053
commit 4acd0180f9

View File

@ -46,6 +46,17 @@ describe ValidatesTimeliness::Validator do
Person.validates_date :birth_date, :allow_nil => true
valid!(:birth_date, NIL)
end
context "with raw value cache" do
it "should not be valid with an invalid format" do
PersonWithShim.validates_date :birth_date, :allow_nil => true
p = PersonWithShim.new
p.birth_date = 'bogus'
p.should_not be_valid
end
end
end
describe ":allow_blank option" do
@ -59,6 +70,17 @@ describe ValidatesTimeliness::Validator do
Person.validates_date :birth_date, :allow_blank => true
valid!(:birth_date, '')
end
context "with raw value cache" do
it "should not be valid with an invalid format" do
PersonWithShim.validates_date :birth_date, :allow_blank => true
p = PersonWithShim.new
p.birth_date = 'bogus'
p.should_not be_valid
end
end
end
describe ":between option" do