From 4acd0180f923a479c0b7680e4cf449dd36b0d0a9 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Wed, 1 Feb 2012 21:25:42 +1100 Subject: [PATCH] Add specs for allow_nil and allow_blank with attribute value cache active --- spec/validates_timeliness/validator_spec.rb | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/validates_timeliness/validator_spec.rb b/spec/validates_timeliness/validator_spec.rb index 83f8845..0a0f0c1 100644 --- a/spec/validates_timeliness/validator_spec.rb +++ b/spec/validates_timeliness/validator_spec.rb @@ -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