From 58c2389a7bee54522282d8d0463d46782353def8 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Jul 2016 12:54:38 +1000 Subject: [PATCH] FEATURE: in dev use #focus to focus on failing test (comment should be just above the def line) --- lib/autospec/manager.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/autospec/manager.rb b/lib/autospec/manager.rb index 9034183bc5b..4505dd905f0 100644 --- a/lib/autospec/manager.rb +++ b/lib/autospec/manager.rb @@ -139,7 +139,22 @@ class Autospec::Manager @queue.shift if current[0] == "focus" # focus on the first 10 failed specs failed_specs = runner.failed_specs[0..10] - puts "@@@@@@@@@@@@ failed_spces --> #{failed_specs}" if @debug + puts "@@@@@@@@@@@@ failed_specs --> #{failed_specs}" if @debug + + # try focus tag + if failed_specs.length > 0 + filename,_ = failed_specs[0].split(":") + if filename + spec = File.read(filename) + start,_ = spec.split(/\S*#focus\S*$/) + if start.length < spec.length + line = start.scan(/\n/).length + 1 + puts "Found #focus tag on line #{line}!" + failed_specs = ["#{filename}:#{line+1}"] + end + end + end + # focus on the failed specs @queue.unshift ["focus", failed_specs.join(" "), runner] if failed_specs.length > 0 end