Sha256: 05dce0029515bc894946d1f412e8f2a006edd08271dfd23541cd914262e09ecc

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

require(File.join(File.dirname(__FILE__), '..', 'date_spec_helper'))

describe "Date#<=>" do

  it "should be able to compare two same dates" do
    (Date.civil(2000, 04, 06) <=> Date.civil(2000, 04, 06)).should == 0
  end

  it "should be able to compute the difference between two dates" do
    (Date.civil(2000, 04, 05) <=> Date.civil(2000, 04, 06)).should == -1
    (Date.civil(2001, 04, 05) <=> Date.civil(2000, 04, 06)).should == 1
  end

  it "should be able to compare to another numeric" do
    (Date.civil(2000, 04, 05) <=> Date.civil(2000, 04, 06).jd).should == -1
    (Date.civil(2001, 04, 05) <=> Date.civil(2000, 04, 06).jd).should == 1
  end

end

describe "Date#between?" do
   it "should be true if the date falls in between the two given dates" do
    (Date.civil(2000, 04, 06).between?(Date.civil(2000, 04, 05), Date.civil(2000, 04, 07))).should == true
    (Date.civil(2000, 04, 06).between?(Date.civil(2000, 04, 06), Date.civil(2000, 04, 07))).should == true
    (Date.civil(2000, 04, 06).between?(Date.civil(2000, 04, 05), Date.civil(2000, 04, 06))).should == true
  end 
  
   it "should be false if the date does not fall in between the two given dates" do
    (Date.civil(2000, 04, 05).between?(Date.civil(2000, 04, 06), Date.civil(2000, 04, 07))).should == false
  end 
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
third_base-1.3.0 spec/date/boat_spec.rb
third_base-1.2.0 spec/date/boat_spec.rb
third_base-1.1.1 spec/date/boat_spec.rb
third_base-1.0.1 spec/date/boat_spec.rb
third_base-1.0.0 spec/date/boat_spec.rb
third_base-1.1.0 spec/date/boat_spec.rb