Skip to content

Commit

Permalink
Simplify regexp and out of range specs for Time.new(String)
Browse files Browse the repository at this point in the history
  • Loading branch information
rwstauner authored and eregon committed Nov 6, 2024
1 parent 822b091 commit e80f0c1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/time/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -621,31 +621,31 @@ def obj.to_int; 3; end
it "raises ArgumentError if date/time parts values are not valid" do
-> {
Time.new("2020-13-25 00:56:17 +09:00")
}.should raise_error(ArgumentError, /mon out of range|can't parse:/)
}.should raise_error(ArgumentError, /(mon|argument) out of range/)

-> {
Time.new("2020-12-32 00:56:17 +09:00")
}.should raise_error(ArgumentError, /mday out of range|can't parse:/)
}.should raise_error(ArgumentError, /(mday|argument) out of range/)

-> {
Time.new("2020-12-25 25:56:17 +09:00")
}.should raise_error(ArgumentError, /hour out of range|can't parse:/)
}.should raise_error(ArgumentError, /(hour|argument) out of range/)

-> {
Time.new("2020-12-25 00:61:17 +09:00")
}.should raise_error(ArgumentError, /min out of range|can't parse:/)
}.should raise_error(ArgumentError, /(min|argument) out of range/)

-> {
Time.new("2020-12-25 00:56:61 +09:00")
}.should raise_error(ArgumentError, /sec out of range|can't parse:/)
}.should raise_error(ArgumentError, /(sec|argument) out of range/)

-> {
Time.new("2020-12-25 00:56:17 +23:59:60")
}.should raise_error(ArgumentError, /utc_offset|can't parse:/)
}.should raise_error(ArgumentError, /(utc_offset|argument) out of range/)

-> {
Time.new("2020-12-25 00:56:17 +24:00")
}.should raise_error(ArgumentError, /utc_offset|can't parse:/)
}.should raise_error(ArgumentError, /(utc_offset|argument) out of range/)

-> {
Time.new("2020-12-25 00:56:17 +23:61")
Expand Down

0 comments on commit e80f0c1

Please sign in to comment.