Sha256: 2da11bc3be86d519cae15e671d357847fd7c1dac40b59e82690d2312be3e4e2a
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require(File.join(File.dirname(__FILE__), '..', 'datetime_spec_helper')) describe "DateTime#+" do it "should add a number of days to a Date" do (DateTime.civil(2007,2,27) + 315).should == DateTime.civil(2008, 1, 8) (DateTime.commercial(2007,2,2) + 315).should == DateTime.commercial(2007, 47, 2) (DateTime.jd(2454782) + 315).should == DateTime.jd(2455097) (DateTime.ordinal(2008, 10) + 315).should == DateTime.ordinal(2008, 325) end it "should add a fractional number of days to a Date" do (DateTime.civil(2007,2,27) + 315.5).should == DateTime.civil(2008, 1, 8, 12) (DateTime.commercial(2007,2,2) + 315.75).should == DateTime.commercial(2007, 47, 2, 18) (DateTime.jd(2454782) + 315.25).should == DateTime.jd(2455097, 6) (DateTime.ordinal(2008, 10) + 315.25).should == DateTime.ordinal(2008, 325, 6) end it "should add a negative number of days to a Date" do d = DateTime.civil(2007,2,27).+(-10) d.should == DateTime.civil(2007, 2, 17) end it "should add a fractional negative number of days to a Date" do d = DateTime.civil(2007,2,27).+(-10.5) d.should == DateTime.civil(2007, 2, 16, 12) end it "should raise an error on non numeric parameters" do lambda { DateTime.civil(2007,2,27) + :hello }.should raise_error(TypeError) lambda { DateTime.civil(2007,2,27) + "hello" }.should raise_error(TypeError) lambda { DateTime.civil(2007,2,27) + DateTime.new(2007,2,27) }.should raise_error(TypeError) lambda { DateTime.civil(2007,2,27) + Object.new }.should raise_error(TypeError) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
third_base-1.0.0 | spec/datetime/add_spec.rb |
third_base-1.0.1 | spec/datetime/add_spec.rb |