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.rb18
-rw-r--r--spec/ruby/library/date/shared/month.rb6
-rw-r--r--spec/ruby/library/date/shared/new_bang.rb14
-rw-r--r--spec/ruby/library/date/shared/parse.rb4
-rw-r--r--spec/ruby/library/date/shared/parse_eu.rb8
-rw-r--r--spec/ruby/library/date/shared/parse_us.rb8
-rw-r--r--spec/ruby/library/date/shared/valid_civil.rb16
-rw-r--r--spec/ruby/library/date/shared/valid_commercial.rb24
-rw-r--r--spec/ruby/library/date/shared/valid_jd.rb30
10 files changed, 62 insertions, 82 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
index 39c9af47b6..f53d83235a 100644
--- a/spec/ruby/library/date/shared/commercial.rb
+++ b/spec/ruby/library/date/shared/commercial.rb
@@ -25,15 +25,15 @@ describe :date_commercial, shared: true do
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, 2004, 53, 1) }.should_not.raise(ArgumentError)
+ -> { Date.send(@method, 2004, 53, 0) }.should.raise(ArgumentError)
+ -> { Date.send(@method, 2004, 53, 8) }.should.raise(ArgumentError)
+ -> { Date.send(@method, 2004, 54, 1) }.should.raise(ArgumentError)
+ -> { Date.send(@method, 2004, 0, 1) }.should.raise(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)
+ -> { Date.send(@method, 2003, 52, 1) }.should_not.raise(ArgumentError)
+ -> { Date.send(@method, 2003, 53, 1) }.should.raise(ArgumentError)
+ -> { Date.send(@method, 2003, 52, 0) }.should.raise(ArgumentError)
+ -> { Date.send(@method, 2003, 52, 8) }.should.raise(ArgumentError)
end
end
diff --git a/spec/ruby/library/date/shared/month.rb b/spec/ruby/library/date/shared/month.rb
new file mode 100644
index 0000000000..5fcb2cbeb0
--- /dev/null
+++ b/spec/ruby/library/date/shared/month.rb
@@ -0,0 +1,6 @@
+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/new_bang.rb b/spec/ruby/library/date/shared/new_bang.rb
deleted file mode 100644
index 90f1b432f0..0000000000
--- a/spec/ruby/library/date/shared/new_bang.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-describe :date_new_bang, shared: true do
-
- it "returns a new Date object set to Astronomical Julian Day 0 if no arguments passed" do
- d = Date.send(@method)
- d.ajd.should == 0
- end
-
- it "accepts astronomical julian day number, offset as a fraction of a day and returns a new Date object" do
- d = Date.send(@method, 10, 0.5)
- d.ajd.should == 10
- d.jd.should == 11
- end
-
-end
diff --git a/spec/ruby/library/date/shared/parse.rb b/spec/ruby/library/date/shared/parse.rb
index 1015285e04..40af908386 100644
--- a/spec/ruby/library/date/shared/parse.rb
+++ b/spec/ruby/library/date/shared/parse.rb
@@ -13,7 +13,7 @@ describe :date_parse, shared: true do
d.day.should == 23
end
- it "can parse a 'mmm DD YYYY' string into a Date object" do
+ it "can parse a 'DD mmm YYYY' string into a Date object" do
d = Date.parse("23#{@sep}feb#{@sep}2008")
d.year.should == 2008
d.month.should == 2
@@ -42,7 +42,7 @@ describe :date_parse, shared: true do
d.should == Date.civil(2005, 11, 5)
end
- it "can parse a year, day and month name into a Date object" do
+ it "can parse a day, month name and year into a Date object" do
d = Date.parse("5th#{@sep}november#{@sep}2005")
d.should == Date.civil(2005, 11, 5)
end
diff --git a/spec/ruby/library/date/shared/parse_eu.rb b/spec/ruby/library/date/shared/parse_eu.rb
index ecb15e3c0e..3819524a57 100644
--- a/spec/ruby/library/date/shared/parse_eu.rb
+++ b/spec/ruby/library/date/shared/parse_eu.rb
@@ -7,28 +7,28 @@ describe :date_parse_eu, shared: true do
d.day.should == 1
end
- it "can parse a MM-DD-YYYY string into a Date object" do
+ it "can parse a DD-MM-YYYY string into a Date object" do
d = Date.parse("10#{@sep}01#{@sep}2007")
d.year.should == 2007
d.month.should == 1
d.day.should == 10
end
- it "can parse a MM-DD-YY string into a Date object" do
+ it "can parse a YY-MM-DD string into a Date object" do
d = Date.parse("10#{@sep}01#{@sep}07")
d.year.should == 2010
d.month.should == 1
d.day.should == 7
end
- it "can parse a MM-DD-YY string into a Date object NOT using the year digits as 20XX" do
+ it "can parse a YY-MM-DD string into a Date object NOT using the year digits as 20XX" do
d = Date.parse("10#{@sep}01#{@sep}07", false)
d.year.should == 10
d.month.should == 1
d.day.should == 7
end
- it "can parse a MM-DD-YY string into a Date object using the year digits as 20XX" do
+ it "can parse a YY-MM-DD string into a Date object using the year digits as 20XX" do
d = Date.parse("10#{@sep}01#{@sep}07", true)
d.year.should == 2010
d.month.should == 1
diff --git a/spec/ruby/library/date/shared/parse_us.rb b/spec/ruby/library/date/shared/parse_us.rb
index 7be62b1af1..17e2fc96c1 100644
--- a/spec/ruby/library/date/shared/parse_us.rb
+++ b/spec/ruby/library/date/shared/parse_us.rb
@@ -6,28 +6,28 @@ describe :date_parse_us, shared: true do
d.day.should == 1
end
- it "parses a MM#{@sep}DD#{@sep}YYYY string into a Date object" do
+ it "parses a DD#{@sep}MM#{@sep}YYYY string into a Date object" do
d = Date.parse("10#{@sep}01#{@sep}2007")
d.year.should == 2007
d.month.should == 1
d.day.should == 10
end
- it "parses a MM#{@sep}DD#{@sep}YY string into a Date object" do
+ it "parses a YY#{@sep}MM#{@sep}DD string into a Date object" do
d = Date.parse("10#{@sep}01#{@sep}07")
d.year.should == 2010
d.month.should == 1
d.day.should == 7
end
- it "parses a MM#{@sep}DD#{@sep}YY string into a Date object NOT using the year digits as 20XX" do
+ it "parses a YY#{@sep}MM#{@sep}DD string into a Date object NOT using the year digits as 20XX" do
d = Date.parse("10#{@sep}01#{@sep}07", false)
d.year.should == 10
d.month.should == 1
d.day.should == 7
end
- it "parses a MM#{@sep}DD#{@sep}YY string into a Date object using the year digits as 20XX" do
+ it "parses a YY#{@sep}MM#{@sep}DD string into a Date object using the year digits as 20XX" do
d = Date.parse("10#{@sep}01#{@sep}07", true)
d.year.should == 2010
d.month.should == 1
diff --git a/spec/ruby/library/date/shared/valid_civil.rb b/spec/ruby/library/date/shared/valid_civil.rb
index 545c207bbe..425fee4d2d 100644
--- a/spec/ruby/library/date/shared/valid_civil.rb
+++ b/spec/ruby/library/date/shared/valid_civil.rb
@@ -9,8 +9,8 @@ describe :date_valid_civil?, shared: true do
# 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
+ Date.send(@method, 1582, 10, 15).should == true
+ Date.send(@method, 1582, 10, 14, Date::ENGLAND).should == true
end
it "returns false if it is not a valid civil date" do
@@ -24,13 +24,13 @@ describe :date_valid_civil?, shared: true do
# -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, 1582, -3, -22).should == false
+ Date.send(@method, 1582, -3, -21).should == true
+ Date.send(@method, 1582, -3, -18).should == true
+ Date.send(@method, 1582, -3, -17).should == true
- Date.send(@method, 2007, -11, -10).should be_true
- Date.send(@method, 2008, -11, -10).should be_true
+ Date.send(@method, 2007, -11, -10).should == true
+ Date.send(@method, 2008, -11, -10).should == true
end
end
diff --git a/spec/ruby/library/date/shared/valid_commercial.rb b/spec/ruby/library/date/shared/valid_commercial.rb
index 117dfe1d3d..573b851fdd 100644
--- a/spec/ruby/library/date/shared/valid_commercial.rb
+++ b/spec/ruby/library/date/shared/valid_commercial.rb
@@ -6,16 +6,16 @@ describe :date_valid_commercial?, shared: true do
# 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
+ Date.send(@method, 1582, 39, 4).should == true
+ Date.send(@method, 1582, 39, 5).should == true
+ Date.send(@method, 1582, 41, 4).should == true
+ Date.send(@method, 1582, 41, 5).should == true
+ Date.send(@method, 1582, 41, 4, Date::ENGLAND).should == true
+ Date.send(@method, 1752, 37, 4, Date::ENGLAND).should == true
end
it "returns false it is not a valid commercial date" do
- Date.send(@method, 1999, 53, 1).should be_false
+ Date.send(@method, 1999, 53, 1).should == false
end
it "handles negative week and day numbers" do
@@ -24,11 +24,11 @@ describe :date_valid_commercial?, shared: true do
# -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
+ Date.send(@method, 1582, -12, -4).should == true
+ Date.send(@method, 1582, -12, -3).should == true
+ Date.send(@method, 2007, -44, -2).should == true
+ Date.send(@method, 2008, -44, -2).should == true
+ Date.send(@method, 1999, -53, -1).should == false
end
end
diff --git a/spec/ruby/library/date/shared/valid_jd.rb b/spec/ruby/library/date/shared/valid_jd.rb
index f6ca3f579d..0c01710208 100644
--- a/spec/ruby/library/date/shared/valid_jd.rb
+++ b/spec/ruby/library/date/shared/valid_jd.rb
@@ -1,32 +1,20 @@
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
+ Date.send(@method, -100).should == true
+ Date.send(@method, 100.0).should == true
+ Date.send(@method, 2**100).should == true
+ Date.send(@method, Rational(1,2)).should == true
end
it "returns false if passed nil" do
- Date.send(@method, nil).should be_false
+ Date.send(@method, nil).should == false
end
- ruby_version_is ''...'2.7' do
- it "returns true if passed symbol" do
- Date.send(@method, :number).should be_true
- end
-
- it "returns true if passed false" do
- Date.send(@method, false).should be_true
- end
+ it "returns false if passed symbol" do
+ Date.send(@method, :number).should == false
end
- ruby_version_is '2.7' do
- 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
+ it "returns false if passed false" do
+ Date.send(@method, false).should == false
end
end