Skip to content

Commit 99ce415

Browse files
committed
Refactor guards for Time.new spec
1 parent b7a26df commit 99ce415

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

spec/ruby/core/time/new_spec.rb

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -522,17 +522,20 @@ def obj.to_int; 3; end
522522
Time.new("2021-12-25 00:00:00.123456789876 +09:00", precision: 3r).subsec.should == 0.123r
523523
end
524524

525-
it "raise TypeError is can't convert precision keyword argument into Integer" do
526-
error_msg =
527-
if "3.3" <= RUBY_VERSION
528-
"no implicit conversion of String into Integer"
529-
else
530-
"no implicit conversion from string"
531-
end
525+
ruby_version_is ""..."3.3" do
526+
it "raise TypeError is can't convert precision keyword argument into Integer" do
527+
-> {
528+
Time.new("2021-12-25 00:00:00.123456789876 +09:00", precision: "")
529+
}.should raise_error(TypeError, "no implicit conversion from string")
530+
end
531+
end
532532

533-
-> {
534-
Time.new("2021-12-25 00:00:00.123456789876 +09:00", precision: "")
535-
}.should raise_error(TypeError, error_msg)
533+
ruby_version_is "3.3" do
534+
it "raise TypeError is can't convert precision keyword argument into Integer" do
535+
-> {
536+
Time.new("2021-12-25 00:00:00.123456789876 +09:00", precision: "")
537+
}.should raise_error(TypeError, "no implicit conversion of String into Integer")
538+
end
536539
end
537540

538541
it "raises ArgumentError if part of time string is missing" do

0 commit comments

Comments
 (0)