2020-12-02 01:50:01 -05:00
|
|
|
ruby_version_is ""..."3.0" do
|
|
|
|
require_relative '../../spec_helper'
|
|
|
|
require_relative 'fixtures/classes'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2020-12-02 01:50:01 -05:00
|
|
|
describe "Time#succ" do
|
|
|
|
it "returns a new time one second later than time" do
|
|
|
|
suppress_warning {
|
|
|
|
@result = Time.at(100).succ
|
|
|
|
}
|
2019-02-07 11:35:33 -05:00
|
|
|
|
2020-12-02 01:50:01 -05:00
|
|
|
@result.should == Time.at(101)
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
|
2020-12-02 01:50:01 -05:00
|
|
|
it "returns a new instance" do
|
|
|
|
time = Time.at(100)
|
2019-02-07 11:35:33 -05:00
|
|
|
|
2020-12-02 01:50:01 -05:00
|
|
|
suppress_warning {
|
|
|
|
@result = time.succ
|
|
|
|
}
|
2019-02-07 11:35:33 -05:00
|
|
|
|
2020-12-02 01:50:01 -05:00
|
|
|
@result.should_not equal time
|
|
|
|
end
|
2019-02-07 11:35:33 -05:00
|
|
|
|
2020-12-02 01:50:01 -05:00
|
|
|
it "is obsolete" do
|
|
|
|
-> {
|
|
|
|
Time.at(100).succ
|
|
|
|
}.should complain(/Time#succ is obsolete/)
|
|
|
|
end
|
2019-02-07 11:35:33 -05:00
|
|
|
|
2020-12-02 01:50:01 -05:00
|
|
|
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) - 1
|
2019-02-07 11:35:33 -05:00
|
|
|
|
2020-12-02 01:50:01 -05:00
|
|
|
time.zone.should == zone
|
|
|
|
end
|
2019-02-07 11:35:33 -05:00
|
|
|
end
|
|
|
|
end
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
end
|