mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
added less than exhaustive datetime format validation specs
This commit is contained in:
parent
8ab82411ca
commit
1d2720ca67
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user