Log slow rspec examples
1 2 module Spec::Example 3 module ExampleMethods 4 THRESHOLD_TO_LOG = 500 # ms 5 6 alias :execute_without_timing :execute 7 def execute_with_timing(options) 8 start_time = Time.now 9 execute_without_timing(options) 10 duration_ms = (Time.now - start_time) * 1000 11 if (duration_ms > THRESHOLD_TO_LOG) 12 print "(#{sprintf("%.3fms", duration_ms)} - #{_example.description}) " 13 end 14 end 15 alias :execute :execute_with_timing 16 end 17 end