summaryrefslogtreecommitdiff
path: root/spec/ruby/core/time/to_i_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/time/to_i_spec.rb')
-rw-r--r--spec/ruby/core/time/to_i_spec.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/ruby/core/time/to_i_spec.rb b/spec/ruby/core/time/to_i_spec.rb
index 54929d1e18..00c4215d31 100644
--- a/spec/ruby/core/time/to_i_spec.rb
+++ b/spec/ruby/core/time/to_i_spec.rb
@@ -1,6 +1,18 @@
require_relative '../../spec_helper'
-require_relative 'shared/to_i'
describe "Time#to_i" do
- it_behaves_like :time_to_i, :to_i
+ it "returns the value of time as an integer number of seconds since epoch" do
+ Time.at(0).to_i.should == 0
+ end
+
+ it "doesn't return an actual number of seconds in time" do
+ Time.at(65.5).to_i.should == 65
+ end
+
+ it "rounds fractional seconds toward zero" do
+ t = Time.utc(1960, 1, 1, 0, 0, 0, 999_999)
+
+ t.to_f.to_i.should == -315619199
+ t.to_i.should == -315619200
+ end
end