diff --git a/core/time/new_spec.rb b/core/time/new_spec.rb index 91ce4b2e3..0cde11c98 100644 --- a/core/time/new_spec.rb +++ b/core/time/new_spec.rb @@ -570,6 +570,23 @@ def obj.to_int; 3; end }.should.raise(ArgumentError, /missing min part: 00 |can't parse:/) end + # These strings end exactly at the byte where the parser expects a ':', so + # the message has no offending byte to append. The other error cases here + # all carry a trailing zone, which left that boundary unexercised. + it "raises ArgumentError if the time string ends where a ':' is expected" do + -> { + Time.new("2020-12-25 00:56") + }.should.raise(ArgumentError, /\Amissing sec part: 00:56\z|can't parse:/) + + -> { + Time.new("2020-12-25T00:56") + }.should.raise(ArgumentError, /\Amissing sec part: 00:56\z|can't parse:/) + + -> { + Time.new("2020-12-25 00") + }.should.raise(ArgumentError, /\Amissing min part: 00\z|can't parse:/) + end + it "raises ArgumentError if the time part is missing" do -> { Time.new("2020-12-25")