2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2019-02-07 11:35:33 -05:00
|
|
|
require_relative 'fixtures/classes'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "Time#succ" do
|
|
|
|
it "returns a new time one second later than time" do
|
2019-02-07 11:35:33 -05:00
|
|
|
suppress_warning {
|
2017-05-07 08:04:49 -04:00
|
|
|
@result = Time.at(100).succ
|
2019-02-07 11:35:33 -05:00
|
|
|
}
|
|
|
|
|
2017-05-07 08:04:49 -04:00
|
|
|
@result.should == Time.at(101)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a new instance" do
|
2019-02-07 11:35:33 -05:00
|
|
|
time = Time.at(100)
|
|
|
|
|
|
|
|
suppress_warning {
|
|
|
|
@result = time.succ
|
|
|
|
}
|
|
|
|
|
|
|
|
@result.should_not equal time
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is obsolete" do
|
|
|
|
lambda {
|
|
|
|
Time.at(100).succ
|
2017-05-07 08:04:49 -04:00
|
|
|
}.should complain(/Time#succ is obsolete/)
|
2019-02-07 11:35:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
ruby_version_is "2.6" do
|
|
|
|
context "zone is a timezone object" do
|
|
|
|
it "preserves time zone" do
|
|
|
|
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
|
|
|
|
time = Time.new(2012, 1, 1, 12, 0, 0, zone) - 60*60
|
|
|
|
|
|
|
|
time.zone.should == zone
|
|
|
|
end
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
end
|