Skip to content

Commit 69ec93e

Browse files
committed
Add ruby_version_is '3.1' guard for Time.now specs related to the :in argument
1 parent 5a97f5a commit 69ec93e

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

spec/ruby/core/time/now_spec.rb

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,50 @@
44
describe "Time.now" do
55
it_behaves_like :time_now, :now
66

7-
describe ":in keyword argument" do
8-
it "could be UTC offset as a String in '+HH:MM or '-HH:MM' format" do
9-
time = Time.now(in: "+05:00")
7+
ruby_version_is '3.1' do # https://bugs.ruby-lang.org/issues/17485
8+
describe ":in keyword argument" do
9+
it "could be UTC offset as a String in '+HH:MM or '-HH:MM' format" do
10+
time = Time.now(in: "+05:00")
1011

11-
time.utc_offset.should == 5*60*60
12-
time.zone.should == nil
12+
time.utc_offset.should == 5*60*60
13+
time.zone.should == nil
1314

14-
time = Time.now(in: "-09:00")
15+
time = Time.now(in: "-09:00")
1516

16-
time.utc_offset.should == -9*60*60
17-
time.zone.should == nil
18-
end
17+
time.utc_offset.should == -9*60*60
18+
time.zone.should == nil
19+
end
1920

20-
it "could be UTC offset as a number of seconds" do
21-
time = Time.now(in: 5*60*60)
21+
it "could be UTC offset as a number of seconds" do
22+
time = Time.now(in: 5*60*60)
2223

23-
time.utc_offset.should == 5*60*60
24-
time.zone.should == nil
24+
time.utc_offset.should == 5*60*60
25+
time.zone.should == nil
2526

26-
time = Time.now(in: -9*60*60)
27+
time = Time.now(in: -9*60*60)
2728

28-
time.utc_offset.should == -9*60*60
29-
time.zone.should == nil
30-
end
29+
time.utc_offset.should == -9*60*60
30+
time.zone.should == nil
31+
end
3132

32-
it "could be a timezone object" do
33-
zone = TimeSpecs::TimezoneWithName.new(name: "Asia/Colombo")
34-
time = Time.now(in: zone)
33+
it "could be a timezone object" do
34+
zone = TimeSpecs::TimezoneWithName.new(name: "Asia/Colombo")
35+
time = Time.now(in: zone)
3536

36-
time.utc_offset.should == 5*3600+30*60
37-
time.zone.should == zone
37+
time.utc_offset.should == 5*3600+30*60
38+
time.zone.should == zone
3839

39-
zone = TimeSpecs::TimezoneWithName.new(name: "PST")
40-
time = Time.now(in: zone)
40+
zone = TimeSpecs::TimezoneWithName.new(name: "PST")
41+
time = Time.now(in: zone)
4142

42-
time.utc_offset.should == -9*60*60
43-
time.zone.should == zone
44-
end
43+
time.utc_offset.should == -9*60*60
44+
time.zone.should == zone
45+
end
4546

46-
it "raises ArgumentError if format is invalid" do
47-
-> { Time.now(in: "+09:99") }.should raise_error(ArgumentError)
48-
-> { Time.now(in: "ABC") }.should raise_error(ArgumentError)
47+
it "raises ArgumentError if format is invalid" do
48+
-> { Time.now(in: "+09:99") }.should raise_error(ArgumentError)
49+
-> { Time.now(in: "ABC") }.should raise_error(ArgumentError)
50+
end
4951
end
5052
end
5153
end

0 commit comments

Comments
 (0)