lib/testrbl.rb in testrbl-0.3.2 vs lib/testrbl.rb in testrbl-0.3.3
- old
+ new
@@ -34,17 +34,17 @@
# usable via external tools like zeus
def self.pattern_from_file(lines, line)
possible_lines = lines[0..(line.to_i-1)].reverse
- last_spaces = " " * 100
- found = possible_lines.map { |line| test_pattern_from_line(line) }.compact
+ found = possible_lines.map { |line| test_pattern_from_line(line) || block_start_from_line(line) }.compact
# pattern and the groups it is nested under (like describe - describe - it)
+ last_spaces = " " * 100
patterns = found.select do |spaces, name|
last_spaces = spaces if spaces.size < last_spaces.size
- end.map(&:last)
+ end.map(&:last).compact
return filter_duplicate_final(patterns).reverse.join(".*") if found.size > 0
raise "no test found before line #{line}"
end
@@ -113,9 +113,15 @@
def self.run(command)
puts command.join(" ")
STDOUT.flush # if exec fails horribly we at least see some output
Kernel.exec *command
+ end
+
+ def self.block_start_from_line(line)
+ if line =~ /^(\s*).* do( \|.*\|)?$/
+ [$1, nil]
+ end
end
def self.test_pattern_from_line(line)
PATTERNS.each do |r|
next unless line =~ r