spec/timeliness/parser_spec.rb in timeliness-0.3.4 vs spec/timeliness/parser_spec.rb in timeliness-0.3.5
- old
+ new
@@ -29,10 +29,18 @@
it "should return nil for invalid date string" do
should_not_parse("2000-02-30")
end
+ it "should return nil for invalid date string where month is '0'" do
+ should_not_parse("0/01/2000")
+ end
+
+ it "should return nil for invalid date string where month is '00'" do
+ should_not_parse("00/01/2000")
+ end
+
it "should return time object for valid time string" do
parse("12:13:14").should be_kind_of(Time)
end
it "should return nil for invalid time string" do
@@ -121,18 +129,26 @@
context "with :datetime type" do
it "should return time object for valid datetime string" do
parse("2000-01-01 12:13:14", :datetime).should == Time.local(2000,1,1,12,13,14)
end
+
+ it "should return nil for invalid date string" do
+ parse("0/01/2000", :datetime).should be_nil
+ end
end
context "with :date type" do
it "should return time object for valid date string" do
parse("2000-01-01", :date).should == Time.local(2000,1,1)
end
it "should ignore time in datetime string" do
parse('2000-02-01 12:13', :date).should == Time.local(2000,2,1)
+ end
+
+ it "should return nil for invalid date string" do
+ parse("0/01/2000", :date).should be_nil
end
end
context "with :time type" do
it "should return time object with a dummy date values" do