spec/timeliness/format_set_spec.rb in timeliness-0.4.0 vs spec/timeliness/format_set_spec.rb in timeliness-0.4.1
- old
+ new
@@ -55,21 +55,22 @@
end
end
context "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']},
+ 'ddd mmm d hh:nn:ss zo yyyy' => {:pass => ['Sat Jul 19 12:00:00 +1000 2008'], :fail => []},
+ 'ddd mmm d hh:nn:ss tz yyyy' => {:pass => ['Sat Jul 19 12:00:00 EST 2008'], :fail => []},
+ 'yyyy-mm-ddThh:nn:sszo' => {:pass => ['2008-07-19T12:00:00+10:00'], :fail => ['2008-07-19T12:00:00Z+10:00']},
+ 'yyyy-mm-ddThh:nn:ss.uzt' => {:pass => ['2019-06-07T03:35:55.100000Z'], :fail => []},
}
format_tests.each do |format, values|
it "should correctly match datetimes in format '#{format}'" do
regexp = compile_regexp(format)
values[:pass].each {|value| expect(value).to match(regexp)}
values[:fail].each {|value| expect(value).not_to match(regexp)}
end
end
end
-
end
context "#match" do
let(:set) { Timeliness::FormatSet.compile(['yyyy-mm-dd', 'dd/mm/yyyy']) }