summaryrefslogtreecommitdiff
path: root/spec/ruby/library/date/constants_spec.rb
blob: ae343f07ecca95a08a1db6d3ac2f0a27a6de73e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'date'
require File.expand_path('../../../spec_helper', __FILE__)

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|
      lambda {
        ary << "Unknown"
      }.should raise_error(RuntimeError, /frozen/)
      ary.compact.each do |name|
        lambda {
          name << "modified"
        }.should raise_error(RuntimeError, /frozen/)
      end
    end
  end

end