Created
September 2, 2016 17:41
-
-
Save noelrappin/5067c7b0d6e614fac50c55b4bd7bc217 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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