diff --git a/test/resource_test.rb b/test/resource_test.rb index 9e895b33..deaac470 100644 --- a/test/resource_test.rb +++ b/test/resource_test.rb @@ -173,7 +173,7 @@ def test_acquire_timeout def test_acquire_and_release_timeout resource = create_resource(:testing, tickets: 1, timeout: 1) - start_time = Time.now.to_f + start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) # Grab the only ticket resource.acquire_semaphore @@ -182,12 +182,13 @@ def test_acquire_and_release_timeout assert_raises(Semian::TimeoutError) do resource.acquire_semaphore end + end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) # Should work now resource.release_semaphore # Ensure we actually waited for the timeout - assert_in_delta(1, Time.now.to_f - start_time, EPSILON) + assert_in_delta(1, end_time - start_time, EPSILON) end def test_release_semaphore_without_acquire