summaryrefslogtreecommitdiff
path: root/spec/ruby/library/date/shared
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/date/shared')
-rw-r--r--spec/ruby/library/date/shared/civil.rb16
-rw-r--r--spec/ruby/library/date/shared/commercial.rb39
-rw-r--r--spec/ruby/library/date/shared/jd.rb14
-rw-r--r--spec/ruby/library/date/shared/month.rb6
-rw-r--r--spec/ruby/library/date/shared/ordinal.rb22
-rw-r--r--spec/ruby/library/date/shared/valid_civil.rb36
-rw-r--r--spec/ruby/library/date/shared/valid_commercial.rb34
-rw-r--r--spec/ruby/library/date/shared/valid_jd.rb20
-rw-r--r--spec/ruby/library/date/shared/valid_ordinal.rb26
9 files changed, 8 insertions, 205 deletions
diff --git a/spec/ruby/library/date/shared/civil.rb b/spec/ruby/library/date/shared/civil.rb
index bbed4a8866..4499cdf8e9 100644
--- a/spec/ruby/library/date/shared/civil.rb
+++ b/spec/ruby/library/date/shared/civil.rb
@@ -36,14 +36,14 @@ describe :date_civil, shared: true do
end
it "doesn't create dates for invalid arguments" do
- -> { Date.send(@method, 2000, 13, 31) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2000, 12, 32) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2000, 2, 30) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 1900, 2, 29) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2000, 2, 29) }.should_not raise_error(ArgumentError)
-
- -> { Date.send(@method, 1582, 10, 14) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 1582, 10, 15) }.should_not raise_error(ArgumentError)
+ -> { Date.send(@method, 2000, 13, 31) }.should.raise(ArgumentError)
+ -> { Date.send(@method, 2000, 12, 32) }.should.raise(ArgumentError)
+ -> { Date.send(@method, 2000, 2, 30) }.should.raise(ArgumentError)
+ -> { Date.send(@method, 1900, 2, 29) }.should.raise(ArgumentError)
+ -> { Date.send(@method, 2000, 2, 29) }.should_not.raise(ArgumentError)
+
+ -> { Date.send(@method, 1582, 10, 14) }.should.raise(ArgumentError)
+ -> { Date.send(@method, 1582, 10, 15) }.should_not.raise(ArgumentError)
end
diff --git a/spec/ruby/library/date/shared/commercial.rb b/spec/ruby/library/date/shared/commercial.rb
deleted file mode 100644
index 39c9af47b6..0000000000
--- a/spec/ruby/library/date/shared/commercial.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-describe :date_commercial, shared: true do
- it "creates a Date for Julian Day Number day 0 by default" do
- d = Date.send(@method)
- d.year.should == -4712
- d.month.should == 1
- d.day.should == 1
- end
-
- it "creates a Date for the monday in the year and week given" do
- d = Date.send(@method, 2000, 1)
- d.year.should == 2000
- d.month.should == 1
- d.day.should == 3
- d.cwday.should == 1
- end
-
- it "creates a Date for the correct day given the year, week and day number" do
- d = Date.send(@method, 2004, 1, 1)
- d.year.should == 2003
- d.month.should == 12
- d.day.should == 29
- d.cwday.should == 1
- d.cweek.should == 1
- d.cwyear.should == 2004
- end
-
- it "creates only Date objects for valid weeks" do
- -> { Date.send(@method, 2004, 53, 1) }.should_not raise_error(ArgumentError)
- -> { Date.send(@method, 2004, 53, 0) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2004, 53, 8) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2004, 54, 1) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2004, 0, 1) }.should raise_error(ArgumentError)
-
- -> { Date.send(@method, 2003, 52, 1) }.should_not raise_error(ArgumentError)
- -> { Date.send(@method, 2003, 53, 1) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2003, 52, 0) }.should raise_error(ArgumentError)
- -> { Date.send(@method, 2003, 52, 8) }.should raise_error(ArgumentError)
- end
-end
diff --git a/spec/ruby/library/date/shared/jd.rb b/spec/ruby/library/date/shared/jd.rb
deleted file mode 100644
index 511557b4f7..0000000000
--- a/spec/ruby/library/date/shared/jd.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-describe :date_jd, shared: true do
- it "constructs a Date object if passed a Julian day" do
- Date.send(@method, 2454482).should == Date.civil(2008, 1, 16)
- end
-
- it "returns a Date object representing Julian day 0 (-4712-01-01) if no arguments passed" do
- Date.send(@method).should == Date.civil(-4712, 1, 1)
- end
-
- it "constructs a Date object if passed a negative number" do
- Date.send(@method, -1).should == Date.civil(-4713, 12, 31)
- end
-
-end
diff --git a/spec/ruby/library/date/shared/month.rb b/spec/ruby/library/date/shared/month.rb
deleted file mode 100644
index 5fcb2cbeb0..0000000000
--- a/spec/ruby/library/date/shared/month.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-describe :date_month, shared: true do
- it "returns the month" do
- m = Date.new(2000, 7, 1).send(@method)
- m.should == 7
- end
-end
diff --git a/spec/ruby/library/date/shared/ordinal.rb b/spec/ruby/library/date/shared/ordinal.rb
deleted file mode 100644
index 4b182d5a25..0000000000
--- a/spec/ruby/library/date/shared/ordinal.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# reference:
-# October 1582 (the Gregorian calendar, Civil Date)
-# S M Tu W Th F S
-# 1 2 3 4 15 16
-# 17 18 19 20 21 22 23
-# 24 25 26 27 28 29 30
-# 31
-
-describe :date_ordinal, shared: true do
- it "constructs a Date object from an ordinal date" do
- # October 1582 (the Gregorian calendar, Ordinal Date)
- # S M Tu W Th F S
- # 274 275 276 277 278 279
- # 280 281 282 283 284 285 286
- # 287 288 289 290 291 292 293
- # 294
- Date.send(@method, 1582, 274).should == Date.civil(1582, 10, 1)
- Date.send(@method, 1582, 277).should == Date.civil(1582, 10, 4)
- Date.send(@method, 1582, 278).should == Date.civil(1582, 10, 15)
- Date.send(@method, 1582, 287, Date::ENGLAND).should == Date.civil(1582, 10, 14, Date::ENGLAND)
- end
-end
diff --git a/spec/ruby/library/date/shared/valid_civil.rb b/spec/ruby/library/date/shared/valid_civil.rb
deleted file mode 100644
index 545c207bbe..0000000000
--- a/spec/ruby/library/date/shared/valid_civil.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-describe :date_valid_civil?, shared: true do
-
- # reference:
- # October 1582 (the Gregorian calendar, Civil Date)
- # S M Tu W Th F S
- # 1 2 3 4 15 16
- # 17 18 19 20 21 22 23
- # 24 25 26 27 28 29 30
- # 31
-
- it "returns true if it is a valid civil date" do
- Date.send(@method, 1582, 10, 15).should be_true
- Date.send(@method, 1582, 10, 14, Date::ENGLAND).should be_true
- end
-
- it "returns false if it is not a valid civil date" do
- Date.send(@method, 1582, 10, 14).should == false
- end
-
- it "handles negative months and days" do
- # October 1582 (the Gregorian calendar, Civil Date)
- # S M Tu W Th F S
- # -21 -20 -19 -18 -17 -16
- # -15 -14 -13 -12 -11 -10 -9
- # -8 -7 -6 -5 -4 -3 -2
- # -1
- Date.send(@method, 1582, -3, -22).should be_false
- Date.send(@method, 1582, -3, -21).should be_true
- Date.send(@method, 1582, -3, -18).should be_true
- Date.send(@method, 1582, -3, -17).should be_true
-
- Date.send(@method, 2007, -11, -10).should be_true
- Date.send(@method, 2008, -11, -10).should be_true
- end
-
-end
diff --git a/spec/ruby/library/date/shared/valid_commercial.rb b/spec/ruby/library/date/shared/valid_commercial.rb
deleted file mode 100644
index 117dfe1d3d..0000000000
--- a/spec/ruby/library/date/shared/valid_commercial.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-describe :date_valid_commercial?, shared: true do
-
- it "returns true if it is a valid commercial date" do
- # October 1582 (the Gregorian calendar, Commercial Date)
- # M Tu W Th F Sa Su
- # 39: 1 2 3 4 5 6 7
- # 40: 1 2 3 4 5 6 7
- # 41: 1 2 3 4 5 6 7
- Date.send(@method, 1582, 39, 4).should be_true
- Date.send(@method, 1582, 39, 5).should be_true
- Date.send(@method, 1582, 41, 4).should be_true
- Date.send(@method, 1582, 41, 5).should be_true
- Date.send(@method, 1582, 41, 4, Date::ENGLAND).should be_true
- Date.send(@method, 1752, 37, 4, Date::ENGLAND).should be_true
- end
-
- it "returns false it is not a valid commercial date" do
- Date.send(@method, 1999, 53, 1).should be_false
- end
-
- it "handles negative week and day numbers" do
- # October 1582 (the Gregorian calendar, Commercial Date)
- # M Tu W Th F Sa Su
- # -12: -7 -6 -5 -4 -3 -2 -1
- # -11: -7 -6 -5 -4 -3 -2 -1
- # -10: -7 -6 -5 -4 -3 -2 -1
- Date.send(@method, 1582, -12, -4).should be_true
- Date.send(@method, 1582, -12, -3).should be_true
- Date.send(@method, 2007, -44, -2).should be_true
- Date.send(@method, 2008, -44, -2).should be_true
- Date.send(@method, 1999, -53, -1).should be_false
- end
-
-end
diff --git a/spec/ruby/library/date/shared/valid_jd.rb b/spec/ruby/library/date/shared/valid_jd.rb
deleted file mode 100644
index e474dfb450..0000000000
--- a/spec/ruby/library/date/shared/valid_jd.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-describe :date_valid_jd?, shared: true do
- it "returns true if passed a number value" do
- Date.send(@method, -100).should be_true
- Date.send(@method, 100.0).should be_true
- Date.send(@method, 2**100).should be_true
- Date.send(@method, Rational(1,2)).should be_true
- end
-
- it "returns false if passed nil" do
- Date.send(@method, nil).should be_false
- end
-
- it "returns false if passed symbol" do
- Date.send(@method, :number).should be_false
- end
-
- it "returns false if passed false" do
- Date.send(@method, false).should be_false
- end
-end
diff --git a/spec/ruby/library/date/shared/valid_ordinal.rb b/spec/ruby/library/date/shared/valid_ordinal.rb
deleted file mode 100644
index 1ed961be23..0000000000
--- a/spec/ruby/library/date/shared/valid_ordinal.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-describe :date_valid_ordinal?, shared: true do
- it "determines if the date is a valid ordinal date" do
- # October 1582 (the Gregorian calendar, Ordinal Date)
- # S M Tu W Th F S
- # 274 275 276 277 278 279
- # 280 281 282 283 284 285 286
- # 287 288 289 290 291 292 293
- # 294
- Date.send(@method, 1582, 277).should == true
- Date.send(@method, 1582, 278).should == true
- Date.send(@method, 1582, 287).should == true
- Date.send(@method, 1582, 288).should == true
- end
-
- it "handles negative day numbers" do
- # October 1582 (the Gregorian calendar, Ordinal Date)
- # S M Tu W Th F S
- # -82 -81 -80 -79 -78 -77
- # -76 -75 -74 -73 -72 -71 -70
- # -69 -68 -67 -66 -65 -64 -63
- # -62
- Date.send(@method, 1582, -79).should == true
- Date.send(@method, 1582, -78).should == true
- Date.send(@method, 2007, -100).should == true
- end
-end