From 1d2720ca67b903fb4ad917a0aedb58d5741d5fd7 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Sat, 19 Jul 2008 17:25:01 +1000 Subject: [PATCH] added less than exhaustive datetime format validation specs --- spec/formats_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/formats_spec.rb b/spec/formats_spec.rb index 86ab381..ee26d32 100644 --- a/spec/formats_spec.rb +++ b/spec/formats_spec.rb @@ -120,6 +120,20 @@ describe ValidatesTimeliness::Formats do end end end + + describe "for datetime formats" do + format_tests = { + 'ddd mmm d hh:nn:ss zo yyyy' => {:pass => ['Sat Jul 19 12:00:00 +1000 2008'], :fail => []}, + 'yyyy-mm-ddThh:nn:ss(?:Z|zo)' => {:pass => ['2008-07-19T12:00:00+10:00', '2008-07-19T12:00:00Z'], :fail => ['2008-07-19T12:00:00Z+10:00']}, + } + format_tests.each do |format, values| + it "should correctly validate datetimes in format '#{format}'" do + regexp = generate_regexp(format) + values[:pass].each {|value| value.should match(regexp)} + values[:fail].each {|value| value.should_not match(regexp)} + end + end + end end describe "removing formats" do