diff options
Diffstat (limited to 'spec/ruby/core/time/to_i_spec.rb')
| -rw-r--r-- | spec/ruby/core/time/to_i_spec.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/spec/ruby/core/time/to_i_spec.rb b/spec/ruby/core/time/to_i_spec.rb index 1a733f02cf..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 File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../shared/to_i', __FILE__) +require_relative '../../spec_helper' 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 |
