diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
commit | 1d15d5f08032acf1b7bceacbb450d617ff6e0931 (patch) | |
tree | a3785a79899302bc149e4a6e72f624ac27dc1f10 /spec/ruby/library/datetime/new_spec.rb | |
parent | 75bfc6440d595bf339007f4fb280fd4d743e89c1 (diff) |
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory.
[Misc #13792] [ruby-core:82287]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/library/datetime/new_spec.rb')
-rw-r--r-- | spec/ruby/library/datetime/new_spec.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/ruby/library/datetime/new_spec.rb b/spec/ruby/library/datetime/new_spec.rb new file mode 100644 index 0000000000..a8275a1951 --- /dev/null +++ b/spec/ruby/library/datetime/new_spec.rb @@ -0,0 +1,52 @@ +require File.expand_path('../../../spec_helper', __FILE__) +require 'date' + +describe "DateTime.new" do + it "sets all values to default if passed no arguments" do + d = DateTime.new + d.year.should == -4712 + d.month.should == 1 + d.day.should == 1 + d.hour.should == 0 + d.min.should == 0 + d.sec.should == 0 + d.sec_fraction.should == 0 + d.offset.should == 0 + end + + it "takes the first argument as year" do + DateTime.new(2011).year.should == 2011 + end + + it "takes the second argument as month" do + DateTime.new(2011, 2).month.should == 2 + end + + it "takes the third argument as day" do + DateTime.new(2011, 2, 3).day.should == 3 + end + + it "takes the forth argument as hour" do + DateTime.new(2011, 2, 3, 4).hour.should == 4 + end + + it "takes the fifth argument as minute" do + DateTime.new(1, 2, 3, 4, 5).min.should == 5 + end + + it "takes the sixth argument as second" do + DateTime.new(1, 2, 3, 4, 5, 6).sec.should == 6 + end + + it "takes the seventh argument as an offset" do + DateTime.new(1, 2, 3, 4, 5, 6, 0.7).offset.should == 0.7 + end + + it "takes the eigth argument as the date of calendar reform" do + DateTime.new(1, 2, 3, 4, 5, 6, 0.7, Date::ITALY).start().should == Date::ITALY + end + + it "raises an error on invalid arguments" do + lambda { new_datetime(minute: 999) }.should raise_error(ArgumentError) + end +end |