1require_relative '../../spec_helper' 2require 'date' 3 4describe "Date#>>" do 5 it "adds the number of months to a Date" do 6 d = Date.civil(2007,2,27) >> 10 7 d.should == Date.civil(2007, 12, 27) 8 end 9 10 it "sets the day to the last day of a month if the day doesn't exist" do 11 d = Date.civil(2008,3,31) >> 1 12 d.should == Date.civil(2008, 4, 30) 13 end 14 15 it "returns the day of the reform if date falls within calendar reform" do 16 calendar_reform_italy = Date.new(1582, 10, 4) 17 d1 = Date.new(1582, 9, 9) >> 1 18 d2 = Date.new(1582, 9, 10) >> 1 19 d1.should == calendar_reform_italy 20 d2.should == calendar_reform_italy 21 end 22 23 it "raise a TypeError when passed a Symbol" do 24 lambda { Date.civil(2007,2,27) >> :hello }.should raise_error(TypeError) 25 end 26 27 it "raise a TypeError when passed a String" do 28 lambda { Date.civil(2007,2,27) >> "hello" }.should raise_error(TypeError) 29 end 30 31 it "raise a TypeError when passed a Date" do 32 lambda { Date.civil(2007,2,27) >> Date.new }.should raise_error(TypeError) 33 end 34 35 it "raise a TypeError when passed an Object" do 36 lambda { Date.civil(2007,2,27) >> Object.new }.should raise_error(TypeError) 37 end 38end 39