Skip to content

Instantly share code, notes, and snippets.

@noelrappin
Created September 2, 2016 17:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noelrappin/5067c7b0d6e614fac50c55b4bd7bc217 to your computer and use it in GitHub Desktop.
Save noelrappin/5067c7b0d6e614fac50c55b4bd7bc217 to your computer and use it in GitHub Desktop.
class UnclaimedSlowTestException < Exception
THRESHOLD = 1
def initialize(example)
@example = example
end
def message
"This spec at #{@example.metadata[:location]} is slower than #{THRESHOLD} seconds.
Either make it faster or mark it as :slow in metadata"
end
end
RSpec.configure do |config|
config.append_after(:each) do |ce|
runtime = ce.clock.now - ce.metadata[:execution_result].started_at
if runtime > UnclaimedSlowTestException::THRESHOLD && !ce.metadata[:slow]
raise UnclaimedSlowTestException.new(ce)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment