From b732dba1d0e71caa49465fde477c9145460eecae Mon Sep 17 00:00:00 2001 From: Herwin Date: Wed, 28 May 2025 19:37:46 +0200 Subject: [PATCH] Add spec for Timeout.timeout with negative duration argument --- library/timeout/timeout_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/timeout/timeout_spec.rb b/library/timeout/timeout_spec.rb index 584b38d8ec..e16bcaea6a 100644 --- a/library/timeout/timeout_spec.rb +++ b/library/timeout/timeout_spec.rb @@ -39,4 +39,12 @@ 42 end.should == 42 end + + ruby_version_is "3.4" do + it "raises an ArgumentError when provided with a negative duration" do + -> { + Timeout.timeout(-1) + }.should raise_error(ArgumentError, "Timeout sec must be a non-negative number") + end + end end