spec/timeliness/formats_spec.rb in timeliness-0.1.1 vs spec/timeliness/formats_spec.rb in timeliness-0.2.0
- old
+ new
@@ -24,11 +24,11 @@
context "with :before option" do
it "should add new format with higher precedence" do
formats.add_formats(:time, "ss:hh:nn", :before => 'hh:nn:ss')
time_array = parser._parse('59:23:58', :time)
- time_array.should == [nil,nil,nil,23,58,59,nil]
+ time_array.should == [nil,nil,nil,23,58,59,nil,nil]
end
it "should raise error if :before format does not exist" do
lambda { formats.add_formats(:time, "ss:hh:nn", :before => 'nn:hh:ss') }.should raise_error
end
@@ -43,21 +43,22 @@
context "remove_formats" do
before do
@default_formats = formats.time_formats.dup
end
- it "should remove format from format array" do
+ it "should remove a single format from the formats array for type" do
formats.remove_formats(:time, 'h.nn_ampm')
- formats.time_formats.should_not include("h o'clock")
+ formats.time_formats.should_not include('h.nn_ampm')
end
- it "should remove multiple formats from format array" do
- formats.remove_formats(:time, 'h.nn_ampm')
- formats.time_formats.should_not include("h o'clock")
+ it "should remove multiple formats from formats array for type" do
+ formats.remove_formats(:time, 'h:nn', 'h.nn_ampm')
+ formats.time_formats.should_not include('h:nn')
+ formats.time_formats.should_not include('h.nn_ampm')
end
- it "should not allow format to be parsed" do
+ it "should prevent parsing of removed format" do
should_parse('2.12am', :time)
formats.remove_formats(:time, 'h.nn_ampm')
should_not_parse('2.12am', :time)
end
@@ -71,23 +72,23 @@
end
end
context "use_euro_formats" do
it "should allow ambiguous date to be parsed as European format" do
- parser._parse('01/02/2000', :date).should == [2000,1,2,nil,nil,nil,nil]
+ parser._parse('01/02/2000', :date).should == [2000,1,2,nil,nil,nil,nil,nil]
formats.use_euro_formats
- parser._parse('01/02/2000', :date).should == [2000,2,1,nil,nil,nil,nil]
+ parser._parse('01/02/2000', :date).should == [2000,2,1,nil,nil,nil,nil,nil]
end
end
context "use_use_formats" do
before do
formats.use_euro_formats
end
it "should allow ambiguous date to be parsed as European format" do
- parser._parse('01/02/2000', :date).should == [2000,2,1,nil,nil,nil,nil]
+ parser._parse('01/02/2000', :date).should == [2000,2,1,nil,nil,nil,nil,nil]
formats.use_us_formats
- parser._parse('01/02/2000', :date).should == [2000,1,2,nil,nil,nil,nil]
+ parser._parse('01/02/2000', :date).should == [2000,1,2,nil,nil,nil,nil,nil]
end
end
end