spec/date_spec.rb in partial-date-1.1.2 vs spec/date_spec.rb in partial-date-1.1.3

- old
+ new

@@ -7,10 +7,14 @@ it "should have a VERSION constant" do PartialDate.const_get('VERSION').should_not be_empty end + it "should return an empty string for an empty date" do + date.to_s.should == "" + end + it "should have a readable value attribute" do date.year = 2000 date.value.should == 20000000 end @@ -164,22 +168,58 @@ date.day.should == 10 end end describe "Comparisons" do - it "should determine if one date is greater than another" do + it "should determine if one date is greater than another based on year" do + a = PartialDate::Date.new {|d| d.year = 2013; } + b = PartialDate::Date.new {|d| d.year = 2012; } + a.should be > b + end + + it "should determine if one date is less than another based on year" do + a = PartialDate::Date.new {|d| d.year = 2011; } + b = PartialDate::Date.new {|d| d.year = 2012; } + a.should be < b + end + + it "should determine if one date is equal to another based on year" do + a = PartialDate::Date.new {|d| d.year = 2012; } + b = PartialDate::Date.new {|d| d.year = 2012; } + a.should be == b + end + + it "should determine if one date is greater than another based on month" do + a = PartialDate::Date.new {|d| d.year = 2012; d.month = 11; } + b = PartialDate::Date.new {|d| d.year = 2012; d.month = 10 } + a.should be > b + end + + it "should determine if one date is less than another based on month" do + a = PartialDate::Date.new {|d| d.year = 2012; d.month = 9; } + b = PartialDate::Date.new {|d| d.year = 2012; d.month = 10 } + a.should be < b + end + + it "should determine if one date is equal to another based on month" do + a = PartialDate::Date.new {|d| d.year = 2012; d.month = 10; } + b = PartialDate::Date.new {|d| d.year = 2012; d.month = 10 } + a.should be == b + end + + it "should determine if one date is greater than another based on day" do a = PartialDate::Date.new {|d| d.year = 2012; d.month = 12; d.day = 31} b = PartialDate::Date.new {|d| d.year = 2012; d.month = 12; d.day = 30} a.should be > b end - it "should determine if one date is less than another" do - a = PartialDate::Date.new {|d| d.year = 2012; d.month = 0; d.day = 0} + it "should determine if one date is less than another based on day" do + a = PartialDate::Date.new {|d| d.year = 2012; d.month = 12; d.day = 29} b = PartialDate::Date.new {|d| d.year = 2012; d.month = 12; d.day = 30} a.should be < b end - it "should determine if one date is equal to another" do + it "should determine if one date is equal to another based on day" do a = PartialDate::Date.new {|d| d.year = 2012; d.month = 12; d.day = 30} b = PartialDate::Date.new {|d| d.year = 2012; d.month = 12; d.day = 30} a.should be == b end end