Skip to content

Commit 763c219

Browse files
Fix flakey test in notifications_test.rb
Example failure: https://buildkite.com/rails/rails/builds/82905#80d6c6ec-943d-4ba3-b360-1ef6c4aa5d89/1012-1022 The test designates the event end time as 0.01 seconds (i.e. 10 milliseconds) after the start time. It then asserts that the event duration is 10 ± 0.0001 milliseconds. This sometimes fails due to floating point precision errors. This commit changes the assertion to instead check that the duration is within 1% of the expected value.
1 parent 7795ded commit 763c219

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

activesupport/test/notifications_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def test_events_are_initialized_with_details
438438
event = event(:foo, time, time + 0.01, random_id, {})
439439

440440
assert_equal :foo, event.name
441-
assert_in_delta 10.0, event.duration, 0.0001
441+
assert_in_epsilon 10.0, event.duration, 0.01
442442
end
443443

444444
def test_event_cpu_time_does_not_raise_error_when_start_or_finished_not_called

0 commit comments

Comments
 (0)