2017-05-07 08:04:49 -04:00
|
|
|
require 'date'
|
2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "Date constants" do
|
|
|
|
|
|
|
|
it "defines JULIAN" do
|
|
|
|
(Date::JULIAN <=> Date::Infinity.new).should == 0
|
|
|
|
end
|
|
|
|
|
|
|
|
it "defines GREGORIAN" do
|
|
|
|
(Date::GREGORIAN <=> -Date::Infinity.new).should == 0
|
|
|
|
end
|
|
|
|
|
|
|
|
it "defines ITALY" do
|
|
|
|
Date::ITALY.should == 2299161 # 1582-10-15
|
|
|
|
end
|
|
|
|
|
|
|
|
it "defines ENGLAND" do
|
|
|
|
Date::ENGLAND.should == 2361222 # 1752-09-14
|
|
|
|
end
|
|
|
|
|
|
|
|
it "defines MONTHNAMES" do
|
|
|
|
Date::MONTHNAMES.should == [nil] + %w(January February March April May June July
|
|
|
|
August September October November December)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "defines DAYNAMES" do
|
|
|
|
Date::DAYNAMES.should == %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "defines ABBR_MONTHNAMES" do
|
|
|
|
Date::ABBR_DAYNAMES.should == %w(Sun Mon Tue Wed Thu Fri Sat)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "freezes MONTHNAMES, DAYNAMES, ABBR_MONTHNAMES, ABBR_DAYSNAMES" do
|
|
|
|
[Date::MONTHNAMES, Date::DAYNAMES, Date::ABBR_MONTHNAMES, Date::ABBR_DAYNAMES].each do |ary|
|
2019-07-27 06:40:09 -04:00
|
|
|
-> {
|
2017-12-01 10:41:50 -05:00
|
|
|
ary << "Unknown"
|
2017-12-27 11:12:47 -05:00
|
|
|
}.should raise_error(frozen_error_class, /frozen/)
|
2017-05-07 08:04:49 -04:00
|
|
|
ary.compact.each do |name|
|
2019-07-27 06:40:09 -04:00
|
|
|
-> {
|
2017-12-01 10:41:50 -05:00
|
|
|
name << "modified"
|
2017-12-27 11:12:47 -05:00
|
|
|
}.should raise_error(frozen_error_class, /frozen/)
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|