diff options
author | Benoit Daloze <[email protected]> | 2023-05-29 18:33:51 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2023-05-29 18:33:51 +0200 |
commit | 99ce41564e8f64155b22d1e1df77fbe7f980133e (patch) | |
tree | 9e05f0020158f209f33978dbe180bffd1b1a1e3f /spec/ruby/core/time | |
parent | b7a26dfa16228cdfeb7e635df1e4f711908c667c (diff) |
Refactor guards for Time.new spec
Diffstat (limited to 'spec/ruby/core/time')
-rw-r--r-- | spec/ruby/core/time/new_spec.rb | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/spec/ruby/core/time/new_spec.rb b/spec/ruby/core/time/new_spec.rb index 6a39cf7ce0..3752cd146d 100644 --- a/spec/ruby/core/time/new_spec.rb +++ b/spec/ruby/core/time/new_spec.rb @@ -522,17 +522,20 @@ describe "Time.new with a timezone argument" do Time.new("2021-12-25 00:00:00.123456789876 +09:00", precision: 3r).subsec.should == 0.123r end - it "raise TypeError is can't convert precision keyword argument into Integer" do - error_msg = - if "3.3" <= RUBY_VERSION - "no implicit conversion of String into Integer" - else - "no implicit conversion from string" - end + ruby_version_is ""..."3.3" do + it "raise TypeError is can't convert precision keyword argument into Integer" do + -> { + Time.new("2021-12-25 00:00:00.123456789876 +09:00", precision: "") + }.should raise_error(TypeError, "no implicit conversion from string") + end + end - -> { - Time.new("2021-12-25 00:00:00.123456789876 +09:00", precision: "") - }.should raise_error(TypeError, error_msg) + ruby_version_is "3.3" do + it "raise TypeError is can't convert precision keyword argument into Integer" do + -> { + Time.new("2021-12-25 00:00:00.123456789876 +09:00", precision: "") + }.should raise_error(TypeError, "no implicit conversion of String into Integer") + end end it "raises ArgumentError if part of time string is missing" do |