Skip to content

Instantly share code, notes, and snippets.

@j16r
Created February 22, 2013 14:33
Show Gist options
  • Save j16r/5013823 to your computer and use it in GitHub Desktop.
Save j16r/5013823 to your computer and use it in GitHub Desktop.
Useful for adding a strict timeout to functionality you need to operate within a certain time frame
config.around(:each) do |example|
if timeout = example.metadata[:timeout]
Benchmark.realtime do
example.call
end.should <= timeout
else
example.call
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment