Skip to content

Commit 219e753

Browse files
authored
Merge pull request rails#52963 from jhawthorn/fix_benchmark_tests
Loosen time assertions
2 parents 7abc8fb + d8f6280 commit 219e753

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

activesupport/test/benchmark_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
class BenchmarkTest < ActiveSupport::TestCase
66
def test_realtime
7-
time = ActiveSupport::Benchmark.realtime { sleep 0.1 }
8-
assert_in_delta 0.1, time, 0.0005
7+
time = ActiveSupport::Benchmark.realtime { sleep 0.01 }
8+
assert_includes (0.01..0.02), time
99
end
1010

1111
def test_realtime_millisecond
12-
ms = ActiveSupport::Benchmark.realtime(:float_millisecond) { sleep 0.1 }
13-
assert_in_delta 100, ms, 0.5
12+
ms = ActiveSupport::Benchmark.realtime(:float_millisecond) { sleep 0.01 }
13+
assert_includes (10..20), ms
1414
end
1515
end

activesupport/test/core_ext/benchmark_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class BenchmarkTest < ActiveSupport::TestCase
77
def test_is_deprecated
88
assert_deprecated(ActiveSupport.deprecator) do
9-
assert_operator Benchmark.ms { }, :>, 0
9+
assert_kind_of Numeric, Benchmark.ms { }
1010
end
1111
end
1212
end

0 commit comments

Comments
 (0)