Skip to content

Commit c6ef94c

Browse files
committed
Prevent specs from running indefinitely
Limit each example to 1 second in case of infinite loops. Can be redefined with timeout: 0 on example metadata.
1 parent 7f879fe commit c6ef94c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

spec/spec_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require "bundler/setup"
22
require 'ice_cube'
3+
require 'timeout'
34

45
begin
56
require 'simplecov'
@@ -69,4 +70,10 @@ def Object.const_missing(sym)
6970
example.run
7071
end
7172
end
73+
74+
config.around :each do |example|
75+
Timeout.timeout(example.metadata.fetch(:timeout, 1)) do
76+
example.run
77+
end
78+
end
7279
end

0 commit comments

Comments
 (0)